IT猫扑网:您身边最放心的安全下载站! 最新更新|软件分类|软件专题|手机版|论坛转贴|软件发布

您当前所在位置:首页数据库MSSQL → SQL Server取汉字拼音的函数展示

SQL Server取汉字拼音的函数展示

时间:2015/6/28来源:IT猫扑网作者:网管联盟我要评论(0)

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

  1. Create function fun_getPY   
  2. (   
  3. @str nvarchar(4000)   
  4. )   
  5. returns nvarchar(4000)   
  6. as   
  7. begin   
  8. declare @word nchar(1),@PY nvarchar(4000)   
  9. set @PY=''   
  10. while len(@str)>0   
  11. begin   
  12. 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. (   
  6. select 'A' as PY,N'驁' as word   
  7. union all select 'B',N'簿'   
  8. union all select 'C',N'錯'   
  9. union all select 'D',N'鵽'   
  10. union all select 'E',N'樲'   
  11. union all select 'F',N'鰒'   
  12. union all select 'G',N'腂'   
  13. union all select 'H',N'夻'   
  14. union all select 'J',N'攈'   
  15. union all select 'K',N'穒'   
  16. union all select 'L',N'鱳'   
  17. union all select 'M',N'旀'   
  18. union all select 'N',N'桛'   
  19. union all select 'O',N'漚'   
  20. union all select 'P',N'曝'   
  21. union all select 'Q',N'囕'   
  22. union all select 'R',N'鶸'   
  23. union all select 'S',N'蜶'   
  24. union all select 'T',N'籜'   
  25. union all select 'W',N'鶩'   
  26. union all select 'X',N'鑂'   
  27. union all select 'Y',N'韻'   
  28. union all select 'Z',N'咗'   
  29. ) T   
  30. where word>=@word collate Chinese_PRC_CS_AS_KS_WS   
  31. order by PY ASC   
  32. )   
  33. else @word   
  34. end)   
  35. set @str=right(@str,len(@str)-1)   
  36. end   
  37. return @PY   
  38. end  

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

关键词标签:SQL Server

相关阅读

文章评论
发表评论

热门文章 SqlServer2005对现有数据进行分区具体步骤SqlServer2005对现有数据进行分区具体步骤sql server系统表损坏的解决方法sql server系统表损坏的解决方法MS-SQL2005服务器登录名、角色、数据库用户MS-SQL2005服务器登录名、角色、数据库用户Access、SQL Server、Oracle常见应用的区别Access、SQL Server、Oracle常见应用的区别

相关下载

人气排行 如何远程备份(还原)SQL2000数据库SQL2000数据库远程导入(导出)数据配置和注册ODBC数据源-odbc数据源配置教程SQL2000和SQL2005数据库服务端口查看或修改SQL Server 2005降级到2000的正确操作步骤修改Sql Server唯一约束教程浅谈JSP JDBC来连接SQL Server 2005的方法SQL Server创建表语句介绍