insert exec 不能嵌套

等不到来世 等不到来世 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
前些天在论坛上看到过一个帖子,
好像完美兄说用下面的方法能巧妙解决insert exec 不能嵌套的问题。
http://topic.csdn.net/u/20091112/20/74132CBF-1570-4673-B12C-2443EA196B06.html


但是我照着做似乎还是不行,再请教一下大家。


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 语句不能嵌套。
...全文
评论 88
收藏 已收藏
分享
返回顶部
等不到来世
疑难问题 22,298 成员 121,727 内容