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

MSSQL
Microsoft SQLServer的版本区别及选择
在SQL Server数据库中为标识(IDENTITY)列插入显式值
访问和更改关系数据,使用MSSQL外联接
一个查看MSSQLServer数据库空间使用情况的存储过程 SpaceUsed
SQL语句去掉重复记录,获取重复记录
复习一下sql server的差异备份
SQL中object_id函数的用法
SQL Server日期计算
找回SQL企业管理器里的SQL连接的密码的方法
mssql数据库系统崩溃后的一般处理步骤与方法
海量数据库的查询优化及分页算法方案
SQL Server连接中三个常见的错误分析
在程序中压缩sql server2000的数据库备份文件的代码
MS SQL SERVER 数据库日志压缩方法与代码
如何远程连接SQL Server数据库的图文教程
复制SqlServer数据库的方法
搜索sql语句
sql中返回参数的值
sql中生成查询的模糊匹配字符串
将Session值储存于SQL Server中

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 111 ::
收藏到网摘: 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