• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

一个sql server中用到的函数,用来取拼音

发布: 2007-7-02 11:08 | 作者: admin | 来源: | 查看: 14次 | 进入软件测试论坛讨论

领测软件测试网 create function f_GetPy(@str nvarchar(4000))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert into @t(chr,letter)
  select @#吖@#,@#A@# union all select @#八@#,@#B@# union all
  select @#嚓@#,@#C@# union all select @#咑@#,@#D@# union all
  select @#妸@#,@#E@# union all select @#发@#,@#F@# union all
  select @#旮@#,@#G@# union all select @#铪@#,@#H@# union all
  select @#丌@#,@#J@# union all select @#咔@#,@#K@# union all
  select @#垃@#,@#L@# union all select @#嘸@#,@#M@# union all
  select @#拏@#,@#N@# union all select @#噢@#,@#O@# union all
  select @#妑@#,@#P@# union all select @#七@#,@#Q@# union all
  select @#呥@#,@#R@# union all select @#仨@#,@#S@# union all
  select @#他@#,@#T@# union all select @#屲@#,@#W@# union all
  select @#夕@#,@#X@# union all select @#丫@#,@#Y@# union all
  select @#帀@#,@#Z@#
  select @strlen=len(@str),@re=@#@#
  while @strlen>0
  begin
    select top 1 @re=letter+@re,@strlen=@strlen-1
      from @t a where chr<=substring(@str,@strlen,1)
      order by chr desc
    if @@rowcount=0
      select @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1
  end
  return(@re)
end
go
--调用
select * from alls where dbo.f_GetPy(name)=@#cyml@#

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网