求一个汉字转拼音的函数,多谢!

mustudent mustudent 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

ALTER function [dbo].[FunGetPy](@Str varchar(500)='')
returns varchar(500)
as
begin
declare @strlen int,@return varchar(500),@ii int
declare @n int,@c char(1),@chn nchar(1)

select @strlen=len(@str),@return='',@ii=0
set @ii=0
while @ii<@strlen
begin
select @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)
if @chn>'z'
select @n = @n +1
,@c = case chn when @chn then char(@n) else @c end
from(
select top 27 * from (
select chn = N'吖'
union all select N'八'
union all select N'嚓'
union all select N'咑'
union all select N'妸'
union all select N'发'
union all select N'旮'
union all select N'铪'
union all select N'丌' --because have no 'i'

union all select N'丌'
union all select N'咔'
union all select N'垃'
union all select N'嘸'
union all select N'拏'
union all select N'噢'
union all select N'妑'
union all select N'七'
union all select N'呥'
union all select N'仨'
union all select N'他'
union all select N'屲' --no 'u'

union all select N'屲' --no 'v'

union all select N'屲'
union all select N'夕'
union all select N'丫'
union all select N'帀'
union all select @chn) as a
order by chn COLLATE Chinese_PRC_CI_AS
) as b
else set @c='a'
set @return=@return+@c
end
return(@return)
end


这个不行啊

Select dbo.FunGetPy('行')
/*
------------------------------------------------
X

(1 行受影响)

//居然是X,而不是H....
*/
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
mustudent
MS-SQL Server 34,876 成员 254,635 内容