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://bzwzjz.com/article/dpohsic.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 企业网站设计 高端定制网站设计 外贸网站设计方案 成都企业网站建设公司 定制级高端网站建设 外贸网站建设 成都网站设计公司 企业网站建设 网站建设方案 响应式网站设计 企业网站制作 温江网站设计 成都网站建设公司 网站设计 重庆电商网站建设 成都网站建设流程 成都网站建设 成都网站设计 成都企业网站制作 外贸营销网站建设 营销型网站建设 温江网站设计