您的位置:首页 > 其它

模糊查询的关键字

2008-02-29 12:49 239 查看
模糊查询的关键字例:

ABC =====>%A%B%C%


create function fun_SearchKey(@temp varchar(50))


------模糊查询的关键字----


RETURNS VARCHAR(100)


AS


BEGIN


DECLARE @temp1 varchar(50),@temp2 varchar(50),@i int,@x int


set @i=len(@temp)


set @x=1


while(@x<=@i)


begin


set @temp1=substring(@temp,0,@x)


set @temp2=substring(@temp,@x,@i)


set @temp=@temp1+'%'+@temp2


set @x=@x+2


set @i=@i+1


end


set @temp=@temp+'%'


return @temp


END



---另一种查询方式---
select * from Customers where PATINDEX('%[ab]c%',CompanyName )<>0

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: