Hello I have a proc called Test_ProcA
and I want to call Test_ProcB
. I created a temp table called #temp
with matching names and data types returned by Test_ProcB
.
How do I insert the result set returned by Test_ProcB
into #temp
. When I try doing that I keep getting this error:
An
INSERT EXEC
statement cannot be nested.
Any ideas and suggestions on what needs to be done.
You're heading for a total maintenance nightmare. Here is an old article (which still receives updates) on the problem you're experiencing with some alternate ways to do the same thing.
http://www.sommarskog.se/share_data.html
when you create a SQL Server stored procedure you can have an INSERT INTO #TempTable from an other exec sp_xxx but you have to control that inside this second one there aren't similar techniques to manage data. You can have only "one level" and the "nested" ones cause the errors.
You'll have to extract the code and manage it inside the first level stored procedure, this is my approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With