create procedure search
@table varchar(50),@column varchar(50),@searchkey varchar(20)
as
select @column from @table where @column like '%@searchkey%'
可能吗?如果没有请建议。谢谢!
答案 0 :(得分:0)
是的,请使用动态编码
create procedure search
@table varchar(50),@column varchar(50),@searchkey varchar(20)
as
BEGIN
DECLARE @QRY VARCHAR(MAX)='select '+@column+' from '+@table+'
where '+@column+' like %'+@searchkey+'%';
EXEC (@QRY);
END