Create  Procedure Proc_insertnews
@id int=null
as 
   if(@id is null)   
   begin  
print '1'   
     end 
   else
      begin
print '2'    
  end Proc_insertnews 2
Proc_insertnews null我试了一下可以的啊

解决方案 »

  1.   

    运行结果是正常的阿不指明的情况下,就用你赋值的默认值阿,也是 null
      

  2.   

    不可能,我刚才试了,在指明@id的值为空或是不指明@id时运行的结果都是过程1:
    Create  Procedure Proc_insertnews
    @id int=null
    as
      if(@id is null)   
        print '过程1'
      else
        print '过程2'
    go调用:
    exec Proc_insertnews
    exec Proc_insertnews null
    exec Proc_insertnews 1
    go返回:
    过程1
    过程1
    过程2