加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 数据库 > MySql > 正文

一个效率很高的汉字转拼音首字母的函数

发布时间:2020-05-23 10:30:40 所属栏目:MySql 来源:互联网
导读:一个效率很高的汉字转拼音首字母的函数

下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。

脚本之家小编现在分享给大家,也给大家做个参考。

create   function   [dbo].[fn_getpy]
(@str   nvarchar(4000)) 
returns   nvarchar(4000) 
as 
begin 
declare   @str_len   int,@result   nvarchar(4000),@crs nvarchar(1)
set @str_len=len(@str)
set @result= ' ' 
    while   @str_len> 0 
    begin 
set  @crs=substring(@str,@str_len,1)
 
   select  @[emailprotected]_len-1,@result=
     case  
     when @crs>='帀' then 'Z'
     when @crs>='丫' then 'Y'
     when @crs>='夕' then 'X'
     when @crs>='屲' then 'W'
     when @crs>='他' then 'T'
     when @crs>='仨' then 'S'
     when @crs>='呥' then 'R'
     when @crs>='七' then 'Q'
     when @crs>='妑' then 'P'
     when @crs>='噢' then 'O'
     when @crs>='拏' then 'N'
     when @crs>='嘸' then 'M'
     when @crs>='垃' then 'L'
     when @crs>='咔' then 'K'
     when @crs>='丌' then 'J'
     when @crs>='铪' then 'H'
     when @crs>='旮' then 'G'
     when @crs>='发' then 'F'
     when @crs>='妸' then 'E'
     when @crs>='咑' then 'D'
     when @crs>='嚓' then 'C'
     when @crs>='八' then 'B'
     when @crs>='吖' then 'A'
     else  @crs  [emailprotected]
    end 
    return(@result) 
end


以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读