SQL Server数据库正确获取汉字字串的拼音声母


  本文标签:SQL Server数据库

  以下的文章主要是对SQL Server数据库中正确获取汉字字串的拼音声母的正确操作步骤的描述,假如你对SQL Server数据库中正确获取汉字字串的拼音声母的正确操作步骤有兴趣了解的话,你就可以浏览以下的文章了  。

  1. CREATE function fGetPy(@str varchar(500)='')  
  2. returns varchar(500)  
  3. as  
  4. begin  
  5. declare @strlen int,@return varchar(500),@ii int  
  6. declare @c nchar(1),@chn nchar(1)  
  7. CREATE function fGetPy(@str varchar(500)=)  
  8. returns varchar(500)  
  9. as  
  10. begin  
  11. declare @strlen int,@return varchar(500),@ii int  
  12. declare @c nchar(1),@chn nchar(1)  
  13. select @strlen=len(@str),@return=,@ii=0 
  14. set @ii=0 
  15. while @ii<@strlen  
  16. begin  
  17. select @ii=@ii+1,@chn=substring(@str,@ii,1)  
  18. if @chn>=吖  
  19. select @c = char(count(*)+63) from (  
  20. select top 27 * from (  
  21. select chn =  
  22. union all select 八  
  23. union all select 嚓  
  24. union all select 咑  
  25. union all select 妸  
  26. union all select 发  
  27. union all select 旮  
  28. union all select 铪  
  29. union all select 丌 --because have no i  
  30. union all select 丌  
  31. union all select 咔  
  32. union all select 垃  
  33. union all select 嘸  
  34. union all select 拏  
  35. union all select 噢  
  36. union all select 妑  
  37. union all select 七  
  38. union all select 呥  
  39. union all select 仨  
  40. union all select 他  
  41. union all select 屲 --no u  
  42. union all select 屲 --no v  
  43. union all select 屲  
  44. union all select 夕  
  45. union all select 丫  
  46. union all select 帀  
  47. union all select @chn  
  48. ) as a  
  49. order by chn COLLATE Chinese_PRC_CI_AS ) as b  
  50. where b.chn <=@chn  
  51. else set @c=@chn  
  52. set @return=@return+@c   
  53. end  
  54. return(@return)  
  55. end  

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