带有output的存储过程:
create procedure pro2
(@a int ,
 @b int,
 @c  int output)
as 
set @c=@a+@b
go调用存储过程:
declare  @c int
exec pro2 4,5,@c
print @c
我想得到@C的结果是不是9呢,
为什么得不到结果?

解决方案 »

  1.   

    declare @c int
    exec pro2 4,5,@c output
    print @c
      

  2.   

    这样就是 9 了.
    create procedure pro2
    (@a int ,
     @b int,
     @c int output)
    as 
    set @c=@a+@b
    go
    declare @c int
    exec pro2 4,5,@c output
    print @c
      

  3.   

    declare @c int
    exec pro2 4,5,@c output
    print @c
      

  4.   

    调用存储过程:
    declare @c int
    exec pro2 4,5,@c outputprint @c
      

  5.   


    create procedure pro2
    (@a int ,
     @b int,
     @c int output)
    as 
    set @c=@a+@b
    godeclare @c int
    exec pro2 4,5,@c output
    print @cdrop proc pro2/****9
      

  6.   

    如果改成:create procedure pro3
    (@a int ,
     @b int)
    as 
    return @a+@b
    go
    怎么得到返回的结果?
      

  7.   

    知道怎么了,谢谢大家啊,
    应该这样得到:declare @c int
    exec @c=pro3 4,5
    print @c