转载自http://blog.csdn.net/xb12369/article/details/8202703 假设存储过程:proc_test create proc proc_test @ProdID varchar(10) as begin declare @sql varchar(max) @sql = " select * from test where 1=1" if @ProdID <> '' set @sql += ' and prodid=''' + @…
假设存储过程:proc_test create proc proc_test @ProdID varchar(10) as begin declare @sql varchar(max) @sql = " select * from test where 1=1" if @ProdID <> '' set @sql += ' and prodid=''' + @ProdID + '''' set @sql += ' order by Id desc' exec @sql…