自定义查询条件的存储过程

create proc abc
(
    @condition varchar(2000)
)
as
begin
 declare @strsql varchar(8000)
 set @strsql='select * from table1
 where 1=1'+@condition+' order by id desc'
 print @strsql
 exec(@strsql)
end

原文地址:https://www.cnblogs.com/yubufan/p/3611809.html