近期的项目因为涉及到存储过程嵌套调用,所以做了一个获取上一层存储过程的输出值的测试
alter proc test1
@id int
,@outP int output
,@outMsg varchar(200) output
as
begin
-- select @id
set @outP=@outP+@id
set @outMsg='输出消息'
-- select @outP
end
go
alter proc test2
@id int
as
begin
declare @rt int
,@outMsg varchar(200)
set @rt=3
exec test1 @id,@rt,@outMsg OUTPUT
select @rt,@outMsg
end
go
exec test2 1
go