转自:http://www.maomao365.com/?p=6801

摘要:
下文将分享"一个存储过程"中如何调用"另一个存储过程的返回结果",并应用到自身的运算中



在实际开发中,我们经常会遇到在一个存储过程中调用另一个存储过程的返回结果(存储过程相互应用),
实现思路:主要采用临时表将存储过程返回的结果集进行存储,然后供另一个存储过程应用。
如下所示:

create proc pr_b 
@a int,@b int
as
begin
select @a as a @b as b 
union all 
select @a+1 as a @b+1 as b 
end
go

-----创建存储过程pr_a,并调用存储过程pr_b的返回结果
create proc pr_a 
as
begin
create table #t (a int,b int) 
insert into #t (a,b)
exec pr_b 120,188

select * from #t

truncate table #t
drop table #t
end
go 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2021-07-31
  • 2022-12-23
  • 2021-11-28
  • 2022-02-05
  • 2022-12-23
相关资源
相似解决方案