mssql按首字母搜素

SQL复制代码
  1. select * from ERP_TravelProducts   
  2. where left(dbo.fun_getPY(TP_Name),1)='w'  
  3.   
  4. create function fun_getPY(@str nvarchar(4000))      
  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)      
  13.   --如果非汉字字符,返回原字符      
  14.   set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901      
  15.   then (select top 1 PY from (      
  16.   select 'A' as PY,N'驁' as word      
  17.   union all select 'B',N'簿'      
  18.   union all select 'C',N'錯'      
  19.   union all select 'D',N'鵽'      
  20.   union all select 'E',N'樲'      
  21.   union all select 'F',N'鰒'      
  22.   union all select 'G',N'腂'      
  23.   union all select 'H',N'夻'      
  24.   union all select 'J',N'攈'      
  25.   union all select 'K',N'穒'      
  26.   union all select 'L',N'鱳'      
  27.   union all select 'M',N'旀'      
  28.   union all select 'N',N'桛'      
  29.   union all select 'O',N'漚'      
  30.   union all select 'P',N'曝'      
  31.   union all select 'Q',N'囕'      
  32.   union all select 'R',N'鶸'      
  33.   union all select 'S',N'蜶'      
  34.   union all select 'T',N'籜'      
  35.   union all select 'W',N'鶩'      
  36.   union all select 'X',N'鑂'      
  37.   union all select 'Y',N'韻'      
  38.   union all select 'Z',N'咗'      
  39.   )T        
  40.   where word>=@word collate Chinese_PRC_CS_AS_KS_WS        
  41.   order by PY ASCelse @word end)      
  42.   set @str=right(@str,len(@str)-1)      
  43.   end      
  44.   return @PY      
  45.   end     


上一篇:AutoCompleteExtender的一个简单例子代码

下一篇:tbody中使用align下面的td也会继承

留下脚印压缩包密码:sosuo8
名字:
全部评论:
申明:本站部分文章来自网络,由于各种原因对文章的来源无从考究,如果您是“ mssql按首字母搜素 ”的原作者,若侵犯您的版权,请与我联系!在此请您原谅我的幼稚和无知!联系方法:email:ahuinan@21cn.com  QQ:106494262

感谢以下网友对网站提出的建议:
1、感谢“蓝树叶kiss”网友发现一个评论漏洞。(2009-2-28)
2、感谢“陈臣”对程序优化和seo方面的建议。(2009-3-18)
文章档案
  • 作者:佚名
  • 来源:转载
  • 日期:2009-12-4 17:22:00
  • 点击:2542
网友投票(您觉得这篇文章怎样?)
loadding...请稍侯......