传入的是@A,@b参数可以写成这样的存储过程select * 
from 表
where (表.字段a=@A or @A is null )
and (表.字段b=@B or @B is null)
不需要写成2的N次方的存储过程的

解决方案 »

  1.   

    这种必填或非填项的检测一般在前端程序中完成.而且也不需要像你这样组合.比如 t1,t2,t3 这三个必填,t4,t5,t6选填:if(t1.text="" or t2.text="" or t3.text="") then   ....end if
    而且有很多的数据验证组件,比如.net下的验证控件,或是web page里用的很多js类的脚本(当然,不能光用js检测,可能会绕过检测直接post,还是需要服务器代码检测)
      

  2.   

    这个应该有很多方法吧:可以用<script>判断或者是<?PHP?>判断或者是用sql语句实现,不过一般是前台先简单判断在后台判断这样子的。不知道楼主是什么个情况?
      

  3.   

    select * 
    from 表 
    where (表.字段a=@A or @A is null ) 
    and (表.字段b=@B or @B is null)