获取一个模糊查询
2009-06-20 15:11
162 查看
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[GetFirstAlpha]
(
@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
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[GetFirstAlpha]
(
@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
相关文章推荐
- 获取手机通讯录联系人(包含模糊查询,dialog自定义,也有一个自定义通知栏)
- mysql 连接查询指的是将两张表或多张表关联到一起进行查询,获取一个表的行与另一个表的行匹配的数据。常见的连接查询包括内连接(等值连接)、左(外)连接、右(外)连接和交叉连接(完全连接)等
- PHP获取生成一个页面的数据库查询次数
- MyBatis映射文件(集合数据的添加与获取,条件查询,模糊查询)
- 当只有一个输入条件的时匹配数据库表中多个字段模糊查询的SQL语句
- mybatis同一个搜索框对多个字段进行模糊查询
- Spring data jpa模糊查询,根据某一个字段,或者多个字段进行模糊查询
- ACCESS模糊查询出现的变态问题,不知道该问题的希望注意,知道内幕的高手还望给小弟一个解释 Thanks
- 时间模糊查询一个很变态的问题!
- 关于Android的查询CPU、流量、内存以及获取一个app的启动activity
- 模糊查询,从数据库获取值,返回前台JSP的方法。
- Hibernate模糊查询的一个问题
- Twitter bootstrap模糊查询插件 ajax获取内容
- sql语句的模糊查询复习及小技巧一个
- spring data mongodb的根据参数模糊查询(传入一个参数查询slideId/slideName中包含这个参数的所有数据)
- MySQL中REGEXP正则查询同一个字段模糊搜索
- javascript模糊查询一个数组
- iOS程序员利用分页和模糊查询技术实现一个App接口
- Java连接HBASE数据库,创建一个表,删除一张表,修改表,输出插入,修改,数据删除,数据获取,显示表信息,过滤查询,分页查询,地理hash
- Mybatis 一个搜索框对多个字段进行模糊查询