素材图片酷 图酷镜像二 | 壁纸酷 壁纸镜像二 | 写真扫图酷 | Free Wallpaper | 贴图论坛 | ·设为首页 ·加入收藏
您现在的位置: 图酷 >> 自习室 >> 编程开发 >> SQL数据库教程 >> 教程正文

  没有公告


SQL Server中取汉字拼音的函数
作者: 佚名
教程来源: 不详
教程等级:           ★★★
教程录入: 烤焦面包
教程审核: tucoo
添加时间: 2007-4-26
点击次数:
字体选择: 【字体:
相关操作: 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
热门信息:
推荐内容:

Create  function fun_getPY
 (
    @str nvarchar(4000)
 )
returns nvarchar(4000)
as
begin
  declare @word nchar(1),@PY nvarchar(4000)

  set @PY=''

  while len(@str)>0
  begin
    set @word=left(@str,1)

    --如果非汉字字符,返回原字符
    set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
               then ( 
                            select top 1 PY 
                            from 
                            ( 
                             select 'A' as PY,N'驁' as word
                             union all select 'B',N'簿'
                             union all select 'C',N'錯'
                     union all select 'D',N'鵽'
                     union all select 'E',N'樲'
                     union all select 'F',N'鰒'
                     union all select 'G',N'腂'
                     union all select 'H',N'夻'
                     union all select 'J',N'攈'
                     union all select 'K',N'穒'
                     union all select 'L',N'鱳'
                     union all select 'M',N'旀'
                     union all select 'N',N'桛'
                     union all select 'O',N'漚'
                     union all select 'P',N'曝'
                     union all select 'Q',N'囕'
                     union all select 'R',N'鶸'
                     union all select 'S',N'蜶'
                     union all select 'T',N'籜'
                     union all select 'W',N'鶩'
                     union all select 'X',N'鑂'
                     union all select 'Y',N'韻'
                     union all select 'Z',N'咗'
                      ) T 
                   where word>=@word collate Chinese_PRC_CS_AS_KS_WS 
                   order by PY ASC
                          ) 
                      else @word 
                 end)
    set @str=right(@str,len(@str)-1)
  end

  return @PY

end

  • 上一篇教程:
  • 下一篇教程:
  • ::版权和投稿说明::
    • 任何媒体、网站或个人转载、链接、转贴或以其他方式复制发表本站文章,在使用时务必注明“稿件来源:图酷”及“www.tucoo.com”字样,多谢。
    • 本站已注明“来源”的文章均为转载稿,本站转载出于传递更多信息之目的。如本站转载稿涉及版权等问题,请来信与本站联系。
    • 如果您有自己原创的作品,请向我们投稿哦!您可以通过Email:gogocat@21cn.com投出自己的作品,赶快行动吧!
    • 如果觉得我们的资源有用,请推荐给朋友,谢谢!
    ::相关教程::
    SQL Server2005发布元年 微软正身企业级应用
    SQL Server 与Oracle的不同点(从微观上)
    SQL Server Compact Edition RC1 发布!
    SQL Server 2005 Reporting Services 初次使用感受
    SQL Server 2005—有关开发的10个最重要的特点
    SQL Server 2005—数据库管理10个最重要的特点
    SQL Artisan数据库访问组件下一版本完善功能概述
    Ms sql server 2005 sp1发布
     
    网友评论:(评论内容只代表网友观点,与本站立场无关!) 发表评论