CREATE PROCEDURE [dbo].[SelWhereInfo]
@table varchar(10),
@strwhere varchar(50) AS
if(@strwhere<>'')
begin
exec('select * from '+@table+' where name like %' + @strwhere + '%' )
end
else
begin
exec('select * from '+@table)
endGO
大家帮忙看看当传入参数执行模糊查询的时候,总说@strwhere 附近有错误exec('select * from '+@table+' where name like %' + @strwhere + '%' )
这句话应该怎样写?
@table varchar(10),
@strwhere varchar(50) AS
if(@strwhere<>'')
begin
exec('select * from '+@table+' where name like %' + @strwhere + '%' )
end
else
begin
exec('select * from '+@table)
endGO
大家帮忙看看当传入参数执行模糊查询的时候,总说@strwhere 附近有错误exec('select * from '+@table+' where name like %' + @strwhere + '%' )
这句话应该怎样写?
exec('select * from '+@table+' where name like ''%'+ @strwhere +'%''' )