ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 取汉字拼音首字母的存储过程(转)

取汉字拼音首字母的存储过程(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-03-03 09:21:05 0 删除 编辑
取汉字拼音首字母的存储过程
create function fun_getpy
(
@str nvarchar(4000)
)
returns nvarchar(4000)
as
begin

declare @word nchar(1),@py nvarchar(4000)

set @py=''

while len(@str)>0
begin
set @word=left(@str,1)

--如果非汉字字符,返回原字符
set @py=@py+(case when unicode(@word) between 19968 and 19968+20901
then (
select top 1 py
from
(
select 'a' as py,n'驁' as word
union all select 'b',n'簿'
union all select 'c',n'錯'
union all select 'd',n'鵽'
union all select 'e',n'樲'
union all select 'f',n'鰒'
union all select 'g',n'腷'
union all select 'h',n'夻'
union all select 'j',n'攈'
union all select 'k',n'穒'
union all select 'l',n'鱳'
union all select 'm',n'旀'
union all select 'n',n'桛'
union all select 'o',n'漚'
union all select 'p',n'曝'
union all select 'q',n'囕'
union all select 'r',n'鷘'
union all select 's',n'蝦'
union all select 't',n'粁'
union all select 'w',n'鷉'
union all select 'x',n'鑢'
union all select 'y',n'韻'
union all select 'z',n'咗'
) t
where word>=@word collate chinese_prc_cs_as_ks_ws
order by py asc
)
else @word
end)
set @str=right(@str,len(@str)-1)
end

return @py

end

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-122675/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    936
  • 访问量
    599423