·您的位置: 首页 » 资源教程 » 编程开发 » 数据库 » 取汉字拼音首字母的存储过程

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

类别: 数据库教程  评论数:0 总得分: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\'?z\'
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\'?h\'
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\'?a\'
union all select \'P\',N\'曝\'
union all select \'Q\',N\'?蒈'
union all select \'R\',N\'?U\'
union all select \'S\',N\'我\'
union all select \'T\',N\'回\'
union all select \'W\',N\'?F\'
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
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1