22,210
社区成员
发帖
与我相关
我的任务
分享
if object_id('p1','p') is not null
drop proc p1
go
create proc p1 as
create table #t(id int)
insert #t select 100
select * from #t
go
if object_id('p2','p') is not null
drop proc p2
go
create proc p2 as
if object_id('tempdb..#t') is not null
insert #t exec p1
else
begin
create table #t(id int)
insert #t exec p1
end
select * from #t
go
if object_id('p3','p') is not null
drop proc p3
go
create proc p3 as
create table #t(id int)
insert #t exec p2
select * from #t
go
exec p1
exec p2
exec p3 --INSERT EXEC 语句不能嵌套。