如果存储过程返回多个结果集,怎么取结果
1个回答
展开全部
create table test
(
id int identity primary key,
name varchar(50)
)
go
insert into test
select 'aaa' union
select 'bbb' union
select 'ccc'
go
select * from test
go
--创建存储过程
if exists(select * from sysobjects where name='proc_test1')
drop procedure proc_test1
go
create procedure proc_test1
as
begin
declare @table table(id int,name varchar(50))
declare @table1 table(id int,name varchar(50))
insert into @table select * from test
insert into @table1 select * from test
select * from @table
select * from @table1
end
--返回表
exec proc_test1
(
id int identity primary key,
name varchar(50)
)
go
insert into test
select 'aaa' union
select 'bbb' union
select 'ccc'
go
select * from test
go
--创建存储过程
if exists(select * from sysobjects where name='proc_test1')
drop procedure proc_test1
go
create procedure proc_test1
as
begin
declare @table table(id int,name varchar(50))
declare @table1 table(id int,name varchar(50))
insert into @table select * from test
insert into @table1 select * from test
select * from @table
select * from @table1
end
--返回表
exec proc_test1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询