对于字符型字段,有一个很方便的方法,假设传递的参数名称是 @Name<br>Select * From xxxx Where 姓名 like '%'+isNull(@Name,'')+'%' <br>此时无论是你传递什么值,都能达到你想要的结果。<br><br>对于数值型字段,只能通过判断语句,构造了<br><br>Create procedure xxxx <br>declare @Name varchar(20)<br>declare @Age int<br>as<br>Set Nocount on<br>Declare @Sql varchar(4000)<br>Set @Sql='Select * From xxxx Where 姓名 like ''%'+isNull(@Name,'')+'%''' + <br> Case When isNull(@Age,0) = 0 then ' ' else ' And 年龄='+cast(@Age as varchar(20)) end<br><br>Exec(@Sql)<br><br>go