create procedure test1 as begin select * from a select * from b endthis will return two result set.how can i get the second result set.if below procedure store , i know how to docreate procedure test2 as begin select * from a endinsert into #Tem execute test2use this i can get the result set.
这种情况tsql没有直接的方法,一般需要变通处理 针对存储过程 create procedure test1 as begin select * from a select * from b end 1)如果表a和表b结构一致,他们的返回结果集应该合并了,是能取到完整数据 2)如果表a和表b结构不一致,那么将其中一个表返回到实体表或者全局临时表中去如下: create procedure test1 as begin select * from a select * into ##b from b end --获取结果集 declare @a table(....) insert into @a exec test1select * from @a select * from ##b --删除全局临时表 drop table ##b
as
begin
select * from a
select * from b
endthis will return two result set.how can i get the second result set.if below procedure store , i know how to docreate procedure test2
as
begin
select * from a
endinsert into #Tem execute test2use this i can get the result set.
针对存储过程
create procedure test1
as
begin
select * from a
select * from b
end
1)如果表a和表b结构一致,他们的返回结果集应该合并了,是能取到完整数据
2)如果表a和表b结构不一致,那么将其中一个表返回到实体表或者全局临时表中去如下:
create procedure test1
as
begin
select * from a
select * into ##b from b
end --获取结果集
declare @a table(....)
insert into @a exec test1select * from @a
select * from ##b
--删除全局临时表
drop table ##b