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 作为返回参数 为什么 在存储过程的代码里没用到呢?
请赐教
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 作为返回参数 为什么 在存储过程的代码里没用到呢?
请赐教
可是,@int=@Out OutPut 一般在什么情况下用?
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