create proc sc @a varchar(20), @b varchar(20) , @c varchar(20)
as if @b='like'exec ('select * from itm_mstr where '+@a+' like ''%'+@c+'%''')elseexec('select * from itm_mstr where '+@a+'='''+@c+'''')
as if @b='like'exec ('select * from itm_mstr where '+@a+' like ''%'+@c+'%''')elseexec('select * from itm_mstr where '+@a+'='''+@c+'''')
@a varchar(20),
@b varchar(2) ,
@c varchar(20)
as
if @a='itm_wldm'and @b='='
begin
select * from itm_mstr where itm_wldm=@c
end
else if @a='itm_wldm' and @b='like'
begin
print 'hello'
select * from itm_mstr where itm_wldm like '%'+@c+'%'
end
else if @a='itm_wlgg'and @b='='
begin
select * from itm_mstr where itm_wlgg=@c
end
else
begin
select * from itm_mstr where itm_wlgg like '%'+@c+'%'
endhello出来了吗?
@a varchar(20),
@b varchar(2) ,
@c varchar(20)
as
if @b='like'
set @c='''%'+@c+'%'''exec('select * from itm_mstr where '+@a+' '+@b+' '+@c)
就是出不来
应该是declare @b varchar(4)才对.自己能不能加分?:).....