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

MSSQL
详解SQL Server中数据库快照工作原理
VB应用程序访问SQL Server的常用方法
SQL Server特殊磁带备份及恢复设计
基于SQL Server的C/S数据库应用系统
如何实现SQL Server 2005快速Web分页
关于SQL Server数据库中转储设备分析
从外到内提高SQL Server数据库性能
准备SQL Server 2008透明数据加密
快速升级MySQL系统表
解析:在SQL Server下数据库链接的使用
细化解析:SQL Server 2005 数据库镜像
轻松接触SQL Server 2000实例的命名规则
SQL提供的进行数据传输的实用程序—BCP
SQL Server 2000 作数据库服务器的优点
解析:正确的理解SQL Server和XML支持
轻松了解数据库计算机的概念和发展方向
解析SQL Server数据体系和应用程序逻辑
SQL进行排序、分组、统计的10个新技巧
教你怎样打造SQL Server2000的安全策略
解析SQL Server 2005 溢用之:合并列值

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


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