使用存储过程的参数的OUTPUT选项  

解决方案 »

  1.   

    存储过程的两个返回值?
    return只能返回一个返回值。楼主是指存储过程的返回参数吧?
      

  2.   

    看例子:
    use tempdb
    gocreate proc p1
    @id int output --输出参数
    asset @id = 1
    return 0  --返回值
    gocreate proc p2
    as
    declare @id int
    declare @re_value intexec @re_value = p1 @id outputselect @re_value,@id
    goexec p2
    go/**
    0 1
    **/
    drop proc p1
    drop proc p2
    go
      

  3.   

    多个输出参数的例子:
    use tempdb
    gocreate proc p1
    @id1 int output, --输出参数1
    @id2 int output --输出参数2
    asset @id1 = 1
    set @id2 = 2
    return 0
    gocreate proc p2
    as
    declare @id1 int
    declare @id2 int
    declare @re_value intexec @re_value = p1 @id1 output,@id2 outputselect @re_value,@id1,@id2
    goexec p2
    go/**
    0 1 2
    **/
    drop proc p1
    drop proc p2
    go
      

  4.   

    第一个存储过程设连个变量作为参数传入存储过程2,在存储过程2中将参数赋值就可以了
    declare @1 int
    declare @2 int
    exec my_proc2 @1 output, @2 output--在存储过程2中将参数赋值就可以了
    select @1
    select @2
      

  5.   

    create proc pa
    as
    declare @v1 int,@v2 int
    exec pb @v1 output,@v2 output
    select @v1,@v2
    gocreate proc pb
    @v1 int output,
    @v2 int output
    as
    set @v1=1
    set @v2=2
    go
    --测试:
    exec pa
    /*
    ----------- -----------
    1           2(1 row(s) affected)
    */
    drop proc pa
    drop proc pb
      

  6.   

    哦,我是那样的
    在存储过程B里面有个FAILURE:
    begin
    SELECT @Tmp_Return AS 'Return',@Tmp_Message AS 'Message'
    end所以我在A存储过程调用了B以后,
    会返回这两个给我的,
    我只是需要@Tmp_Return判断B到底有没有执行成功
    我在查询分析器里面运行A后,
    因为A自己有一个select显示,
    然后他调用B后又有一个select显示
    结果显示两个表了
    搞的外部程序无法读取A的返回
      

  7.   

    问问题的时候不知道是不是说错了,不知道是不是
    FAILURE: 
    begin 
    SELECT @Tmp_Return AS 'Return',@Tmp_Message AS 'Message' 
    end 
    叫做返回值
    呵呵,不怎么懂
    反正是不想调用A后得到两个表返回,
    只需要A的