create proc_Analyse
@b varchar(20),
@c varchar(20)
as
if @b is null and @c is null
select a,b,c from t
else
select a,b,c from t where b=@b and c=@c
go

解决方案 »

  1.   

    --试试
    create proc_Analyse
    @b varchar(20),
    @c varchar(20)
    as
    select a,b,c from t where b=isnull(@b,b) and c=isnull(@c,c)
    go
      

  2.   

    --刚才没仔细看,改改,下班create PROCEDURE proc_Analyse
    @b varchar(20)=null,
    @c varchar(20)=null
    as
    if @b is null and @c is null
    select a,b,c from t
    else
    select a,b,c from t where b=@b and c=@c
    go
      

  3.   

    --我的也不大对,改改。
    create proc_Analyse
    @b varchar(20) = null,
    @c varchar(20) = null
    as
    select a,b,c from t where b=isnull(@b,b) and c=isnull(@c,c)
    go
      

  4.   

    create procedure proc_Analyse
    @b varchar(20) =null,
    @c varchar(20) = null
    asselect a,b,c from t  where b=isnull(@b,b) and c=isnull(@c,c)else 
    go
      

  5.   

    用mengmou()mengmou()的吧,比较简单
      

  6.   

    --再改,参数多了就像这样加。
    create proc proc_Analyse
    @b varchar(20) = null,
    @c varchar(20) = null,
    @d varchar(20) = null
    as
    select a,b,c from t where b=isnull(@b,b) and c=isnull(@c,c) and d = isnull(@d,d)
    go
      

  7.   

    呵呵 真的忘记写PROCEDURE了
    谢谢两位了 结贴