SQLServer中取汉字拼音的函数

来源:互联网 发布:mc天佑知乎 编辑:程序博客网 时间:2024/04/27 23:36
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
.Vyj268{display:none;}

Create functionfun_getPY
 (
   @strnvarchar(4000)
 )
returnsnvarchar(4000)
as
begin
 declare@wordnchar(1),@PYnvarchar(4000)

 set@PY=''

 whilelen(@str)>0
 begin
   set@word=left(@str,1)

   --如果非汉字字符,返回原字符
   set@PY=@PY+(casewhenunicode(@word)between19968and19968+20901
              then( 
                           selecttop1PY 
                           from 
                           ( 
                            select'A'asPY,N'驁'asword
                            unionallselect'B',N'簿'
                            unionallselect'C',N'錯'
                    unionallselect'D',N'鵽'
                    unionallselect'E',N'樲'
                    unionallselect'F',N'鰒'
                    unionallselect'G',N'腂'
                    unionallselect'H',N'夻'
                    unionallselect'J',N'攈'


                    unionallselect'K',N'穒'
                    unionallselect'L',N'鱳'
                    unionallselect'M',N'旀'
                    unionallselect'N',N'桛'
                    unionallselect'O',N'漚'
                    unionallselect'P',N'曝'
                    unionallselect'Q',N'囕'
                    unionallselect'R',N'鶸'
                    unionallselect'S',N'蜶'
                    unionallselect'T',N'籜'
                    unionallselect'W',N'鶩'
                    unionallselect'X',N'鑂'
                    unionallselect'Y',N'韻'
                    unionallselect'Z',N'咗'
                     )T 
                  whereword>=@wordcollateChinese_PRC_CS_AS_KS_WS 
                  orderbyPYASC
                         ) 
                     else@word 
                end)
   set@str=right(@str,len(@str)-1)
 end

 return@PY

end

请作者联系本站,及时附注您的姓名。联系邮箱:edu#chinaz(把#改为@)。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击