求一段拼音简写的代码

来源:百度知道 编辑:UC知道 时间:2024/06/10 05:07:48
要求如下:
王伟-(WW)
赵伟-(ZW)
张辽-(ZL)
可以是触发器,也可以是存储过程。必须是测试成功的。
在线等。一下子想不起来那些变量了。

你运气真好,我刚好有一个现成的。
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER 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
then (select top 1 PY from (
select 'A' as PY,N'骜' as word
union all select 'B',N'簿'
union all select 'C',N'错'
union all select 'D',N'鵽'
union all select 'E',N'樲'
union all select 'F',N'鳆'
union all select 'G',N'腂'
union all s