漢字轉爲拼音碼 (轉)

  1. declare @strlen int,@return varchar(500),@ii int  
  2. declare @n int,@c char(1),@chn nchar(1),@str varchar(500)  
  3. set @str = '我愛偉大的周星馳'  
  4. select @strlen=len(@str),@return='',@ii=0  
  5. while @ii<@strlen  
  6. begin  
  7. select @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)  
  8. if @chn>'z'  
  9. begin  
  10.                  --select @c,char(@n)  
  11. select @n = @n +1  
  12. ,@c = case chn when @chn then char(@n) else @c end  
  13. from(  
  14. select top 27 * from (  
  15. select chn = '吖'  
  16. union all select '八'  
  17. union all select '嚓'  
  18. union all select '咑'  
  19. union all select '妸'  
  20. union all select '發'  
  21. union all select '旮'  
  22. union all select '鉿'  
  23. union all select '丌' --because have no 'i'  
  24. union all select '丌'  
  25. union all select '咔'  
  26. union all select '垃'  
  27. union all select '嘸'  
  28. union all select '拏'  
  29. union all select '噢'  
  30. union all select '妑'  
  31. union all select '七'  
  32. union all select '呥'  
  33. union all select '仨'  
  34. union all select '他'  
  35. union all select '屲' --no 'u'  
  36. union all select '屲' --no 'v'  
  37. union all select '屲'  
  38. union all select '夕'  
  39. union all select '丫'  
  40. union all select '帀'  
  41. union all select @chn) as a  
  42. order by chn --COLLATE Chinese_PRC_CI_AS  
  43. as b  
  44.                     -- select @chn,@c  
  45. end  
  46. else set @c='a'  
  47. set @return=@return+@c  
  48. end  
  49. select @return  
  50. --SELECT CHAR(64)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章