USE db_mrsql
GO
CREATE PROCEDURE CRE_RET
@ID int=0,
@Int int OutPut
AS
if @ID=0
begin
  Print '错误:必须入@ID参数'
  Return 1
end
else
begin
  if (select count(*) from tb_table11 where UserID=@id)=0
  begin
    Print '错误:@ID参数无效'  
    Return 2
  end
end
select * from tb_table11 where UserID=@id
if @@ERROR=0
  Return 0
else
  Return 3
GO
--执行存储过程
Declare @cost int,@Out int
EXEC @cost=CRE_RET @id=3,@int=@Out OutPut在整个过程中的代码中 @int都没用上 然后在应用程序中又出现 ,@int=@Out OutPut 这句代码有什么用处?
既然@int 作为返回参数 为什么 在存储过程的代码里没用到呢?
请赐教

解决方案 »

  1.   

    是多余了,是通过return返回了
      

  2.   

    哦 这样啊  那如果要用到的,@int=@Out OutPut 话 一般是什么情况下用呢?
      

  3.   

    哦谢谢 
    可是,@int=@Out OutPut 一般在什么情况下用?
      

  4.   

    USE db_mrsql 
    GO 
    CREATE PROCEDURE CRE_RET 
    @ID int=0, 
    @Int int OutPut 
    AS 
    if @ID=0 
    begin 
      Print '错误:必须入@ID参数' 
      set @Int = 1 
    end 
    else 
    begin 
      if (select count(*) from tb_table11 where UserID=@id)=0 
      begin 
        Print '错误:@ID参数无效'  
        set @Int =  2 
      end 
    end 
    select * from tb_table11 where UserID=@id 
    if @@ERROR=0 
      set @Int =  0 
    else 
      set @Int =  3 
    GO 
    --执行存储过程 
    Declare @cost int,@Out int 
    EXEC @cost=CRE_RET @id=3,@int=@Out OutPut 
      

  5.   

    @int=@Out  @Out 又起到什么作用?它在这里为什么要赋值给@int?