sql_server自动生成拼音码

时间:2022-03-27 00:46:22 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
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.wddqw.com/doc/9ee243dd71fe910ef12df8ef.html