首页 | 站长技术 专题 | 下载频道 | 网页模板 | 图片素材 | 虚拟主机 | 项目市场 | 源码市场 | 本站产品 | 广告服务 | 建站论坛
文档首页
建站指南
网站编程
网站设计
图像动画
网络安全
服务器技术
数据库技术
技术专题
技术问答
您的位置:中国建站 > 站长技术 > 数据库技术 > MYSQL > SQL Server中取汉字拼音的函数

SQL Server中取汉字拼音的函数

加入时间:2007-04-30

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

上一篇文章:C# 怎样实现远程连接SQL Server2005
下一篇文章:SQL扩展存储过程安装与卸载
返回上页】 
 

本站在线服务QQ  程序定制:70632246 广告受理/投搞/投诉:7606208 技术客服:3828351
网站简介 广告服务 成功案例 联系方式 办公电话:0580-3825369
Copyright © 2001-2007 JZ173.COM,All rights reserved  浙ICP备05023962号 感谢【中国商务网】提供服务器