青春几米光

点击这里给我发消息

导航

存储过程模糊查询

if exists(select * from sysobjects where name = 'SelectAllProcess' )
drop Proc SelectAllProcess
go
create proc SelectAllProcess
@xingming varchar(15),
@chenghu varchar(15),
@haoma varchar(15),
@fenzu varchar(10)
as
begin
select xingming as 姓名,xingbie as 性别,chenghu as 称呼,haoma as 号码,fenzu as 分组,shijian as 时间
from MemoTable
where xingming like '%'+COALESCE(@xingming,'')+'%' or
   chenghu like '%'+COALESCE(@chenghu,'')+'%' or
   haoma like '%'+COALESCE(@haoma,'')+'%' or
   fenzu like '%'+COALESCE(@fenzu,'')+'%'
end

exec SelectAllProcess @xingming='盼',@chenghu=null,@haoma='13720686947',@fenzu=null

方法二:

 [user].user_account like  '%'+@User_account+'%'

posted on 2012-07-31 18:08  青春几米光  阅读(231)  评论(0编辑  收藏  举报