【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《sql_server自动生成拼音码》,欢迎阅读!
sql server自动生成拼音首字母的函数
建立一个查询,执行下面的语句生成函数fn_GetPy --生成拼音首码
CREATE function getInputstr(@str nvarchar(4000)) returns nvarchar(4000) --WITH ENCRYPTION as
begin
declare @intLen int
declare @strRet nvarchar(4000) declare @temp nvarchar(100) set @intLen = len(@str) set @strRet = '' while @intLen > 0 begin
set @temp = ''
select @temp = case
when substring(@str,@intLen,1) >= '帀' then when substring(@str,@intLen,1) >= '丫' then when substring(@str,@intLen,1) >= '夕' then when substring(@str,@intLen,1) >= '屲' then when substring(@str,@intLen,1) >= '他' then when substring(@str,@intLen,1) >= '仨' then when substring(@str,@intLen,1) >= '呥' then when substring(@str,@intLen,1) >= '七' then when substring(@str,@intLen,1) >= '妑' then when substring(@str,@intLen,1) >= '噢' then when substring(@str,@intLen,1) >= '拏' then when substring(@str,@intLen,1) >= '嘸' then when substring(@str,@intLen,1) >= '垃' then when substring(@str,@intLen,1) >= '咔' then when substring(@str,@intLen,1) >= '丌' then when substring(@str,@intLen,1) >= '铪' then when substring(@str,@intLen,1) >= '旮' then when substring(@str,@intLen,1) >= '发' then when substring(@str,@intLen,1) >= '妸' then when substring(@str,@intLen,1) >= '咑' then when substring(@str,@intLen,1) >= '嚓' then when substring(@str,@intLen,1) >= '八' then when substring(@str,@intLen,1) >= '吖' then else rtrim(ltrim(substring(@str,@intLen,1))) end
--对于汉字特殊字符,不生成拼音码
'Z' 'Y' 'X' 'W' 'T' 'S' 'R' 'Q' 'P' 'O' 'N' 'M' 'L' 'K' 'J' 'H' 'G' 'F' 'E' 'D' 'C' 'B' 'A'
if (ascii(@temp)>127) set @temp = '' --对于英文中小括号,不生成拼音码
if @temp = '(' or @temp = ')' set @temp = '' select @strRet = @temp + @strRet set @intLen = @intLen - 1 end
return lower(@strRet) end
本文来源:https://www.wddqxz.cn/9ee243dd71fe910ef12df8ef.html