SQLServer取汉字拼音的函数展示

此文章主要介绍的是SQL Server取汉字拼音的函数,如果你对SQL Server取汉字拼音的函数心存好奇的话,以下的文章将会揭开它的神秘面纱,以下就是文章的详细内容介绍,望大家借鉴。

 
 
 
  1. Create function fun_getPY 
  2. @str nvarchar(4000) 
  3. returns nvarchar(4000) 
  4. as 
  5. begin 
  6. declare @word nchar(1),@PY nvarchar(4000) 
  7. set @PY='' 
  8. while len(@str)>0 
  9. begin 
  10. set @word=left(@str,1) 

如果非汉字字符,返回原字符

 
 
 
  1. set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901 
  2. then ( 
  3. select top 1 PY 
  4. from 
  5. select 'A' as PY,N'驁' as word 
  6. union all select 'B',N'簿' 
  7. union all select 'C',N'錯' 
  8. union all select 'D',N'鵽' 
  9. union all select 'E',N'樲' 
  10. union all select 'F',N'鰒' 
  11. union all select 'G',N'腂' 
  12. union all select 'H',N'夻' 
  13. union all select 'J',N'攈' 
  14. union all select 'K',N'穒' 
  15. union all select 'L',N'鱳' 
  16. union all select 'M',N'旀' 
  17. union all select 'N',N'桛' 
  18. union all select 'O',N'漚' 
  19. union all select 'P',N'曝' 
  20. union all select 'Q',N'囕' 
  21. union all select 'R',N'鶸' 
  22. union all select 'S',N'蜶' 
  23. union all select 'T',N'籜' 
  24. union all select 'W',N'鶩' 
  25. union all select 'X',N'鑂' 
  26. union all select 'Y',N'韻' 
  27. union all select 'Z',N'咗' 
  28. ) T 
  29. where word>=@word collate Chinese_PRC_CS_AS_KS_WS 
  30. order by PY ASC 
  31. else @word 
  32. end) 
  33. set @str=right(@str,len(@str)-1) 
  34. end 
  35. return @PY 
  36. end

以上的相关内容就是对SQL Server取汉字拼音的函数的介绍,望你能有所收获。


本文名称:SQLServer取汉字拼音的函数展示
网站路径:http://hxwzsj.com/article/dpohsic.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 企业网站设计 专业网站建设 公司网站建设 定制网站建设多少钱 网站建设公司 阿坝网站设计 重庆外贸网站建设 成都网站建设 四川成都网站设计 成都网站设计 成都网站建设公司 手机网站建设套餐 成都网站建设 网站建设改版 网站设计 成都网站建设 高端网站设计 外贸网站设计方案 成都网站建设 成都网站建设 成都网站建设 营销型网站建设