存储过程模糊查询
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+'%'