贡献一段汉字转拼音码的函数
<P>--取出汉字的拼音首码<BR>--入参:汉字字符串<BR>--出参:汉字字符串首拼音码<BR>CREATE function Fun_GetPY <BR> ( <BR> @str nvarchar(4000) <BR> ) <BR>returns nvarchar(4000) <BR>as <BR>begin </P><P> declare @word nchar(1),@PY nvarchar(4000) </P>
<P> set @PY='' </P>
<P> while len(@str)>0 <BR> begin <BR> set @word=left(@str,1) </P>
<P> --如果非汉字字符,返回原字符 <BR> set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901 <BR> then ( <BR> select top 1 PY <BR> from <BR> ( <BR> select 'A' as PY,N'驁' as word <BR> union all select 'B',N'簿' <BR> union all select 'C',N'錯' <BR> union all select 'D',N'鵽' <BR> union all select 'E',N'樲' <BR> union all select 'F',N'鰒' <BR> union all select 'G',N'腂' <BR> union all select 'H',N'夻' <BR> union all select 'J',N'攈' <BR> union all select 'K',N'穒' <BR> union all select 'L',N'鱳' <BR> union all select 'M',N'旀' <BR> union all select 'N',N'桛' <BR> union all select 'O',N'漚' <BR> union all select 'P',N'曝' <BR> union all select 'Q',N'囕' <BR> union all select 'R',N'鶸' <BR> union all select 'S',N'蜶' <BR> union all select 'T',N'籜' <BR> union all select 'W',N'鶩' <BR> union all select 'X',N'鑂' <BR> union all select 'Y',N'韻' <BR> union all select 'Z',N'咗' <BR> ) T <BR> where word>=@word collate Chinese_PRC_CS_AS_KS_WS <BR> order by PY ASC <BR> ) <BR> else @word <BR> end) <BR> set @str=right(@str,len(@str)-1) <BR> end </P>
<P> return @PY </P>
<P>end</P>
顶啊 没有人要用这个东西吗,做系统时要用的 不错,偶给加个精(这个论坛的处女精)[em05] 谢主隆恩<BR><BR> <P>谢谢!<BR></P> *** 作者被禁止或删除 内容自动屏蔽 *** 函数不会用
LZ能给个用这个函数的例题吗?
先谢谢了。 谢谢楼主啊 還行 好东西 收藏了 谢谢
页:
[1]
