create procedure my_d_test
@Year int,
@Month int,
@nFlag int  --旬,没有用到
as 
select * from mytable
where year(OutDate)=@Year and month(OutDate)=@Month
go 
exec procedurer 2004,4,2

解决方案 »

  1.   

    exec my_d_test 2004,4,2
      

  2.   

    zheninchangjiang(john shu) :我没有说清,剩下的该怎样写,
    year(OutDate)=@Year and month(OutDate)=@Month and  ......
    主要是旬部分
      

  3.   

    create procedure my_d_test
    @Year int,
    @Month int,
    @nFlag int output --旬,没有用到
    as 
    @declare @date datetime
    select @date=outdate from mytable
    where year(OutDate)=@Year and month(OutDate)=@Month
    select @nFlag=(case when day(@date) between 1 and 10 then 1 
                  when day(@date) between 11 and 20 then 2 
                  else 3 end)
    go 
    declare @n smallint
    exec my_d_test 2004,4,@n output
    print @nflag