当前位置: 首页 > 图文教程 > 数据库 > MSSQL > sqlServer 获取汉字字串的拼音声母

MSSQL
SQLServer 批量插入数据的两种方法
SQLServer 通用的分区增加和删除的算法
数据库的一些常用知识
SQLServer 连接异常与解决方法小结
sqlserver 无法验证产品密匙的完美解决方案[测试通过]
sql2000 卸载后重新安装时不能安装的解决办法
SQLServer 快速备份的十种方法
sqlserver 中一些常看的指标和清除缓存的方法
SQL 提权 常用命令
数据转换冲突及转换过程中大对象的处理
SQLServer 数据库开发顶级技巧
远程连接SQLSERVER 2000服务器方法
SQLserver2000 企业版 出现"进程51发生了严重的异常"错误的处理方法
SQLServer 触发器 数据库进行数据备份
SQLServer 数据库备份过程中经常遇到的九种情况
SQL 截取字符串应用代码
除MSSQL数据库text字段中恶意脚本的删方法
SQLServer CONVERT 函数测试结果
SQLServer 中.与::的区别
SQL 研究 相似的数据类型

MSSQL 中的 sqlServer 获取汉字字串的拼音声母


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 144 ::
收藏到网摘: n/a

sqlServer 中 获取汉字字串的拼音声母,需要的朋友可以参考下。
复制代码 代码如下:

CREATE function fGetPy(@str varchar(500)='')
returns varchar(500)
as
begin
declare @strlen int,@return varchar(500),@ii int
declare @c nchar(1),@chn nchar(1)
select @strlen=len(@str),@return='',@ii=0
set @ii=0
while @ii<@strlen
begin
select @ii=@ii+1,@chn=substring(@str,@ii,1)
if @chn>='吖'
select @c = char(count(*)+63) from (
select top 27 * from (
select chn = '吖'
union all select '八'
union all select '嚓'
union all select '咑'
union all select '妸'
union all select '发'
union all select '旮'
union all select '铪'
union all select '丌' --because have no 'i'
union all select '丌'
union all select '咔'
union all select '垃'
union all select '嘸'
union all select '拏'
union all select '噢'
union all select '妑'
union all select '七'
union all select '呥'
union all select '仨'
union all select '他'
union all select '屲' --no 'u'
union all select '屲' --no 'v'
union all select '屲'
union all select '夕'
union all select '丫'
union all select '帀'
union all select @chn
) as a
order by chn COLLATE Chinese_PRC_CI_AS ) as b
where b.chn <=@chn
else set @c=@chn
set @return=@return+@c
end
return(@return)
end