Create function fun_getPY
(
@str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
--如果非汉字字符,返回原字符
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
类别: Sqlserver 查看评论
本文介绍了一个 SQL Server 自定义函数 fun_getPY,该函数能够将输入的汉字字符串转换为对应的拼音字符串。通过逐字符读取并判断是否为汉字来实现,非汉字字符则直接返回。

2456

被折叠的 条评论
为什么被折叠?



