title: Is my solution, in my case, for nested INSERT EXEC Statement good?
body: <p>When I run the script below I get error <code>INSERT EXEC Statement cannot be nested</code></p>
  
  <p>Some info regard the stored proc:</p>
  
  <ol>
  <li>Multiply connections may call stored proc <strong>a</strong></li>
  <li>I can't use UDF because in each proc I need to use <strong>IDENTITY_INSERT</strong>, <strong>try...catch blocks</strong></li>
  </ol>
  
  <p>I thought to create table with name <strong>tmp</strong> and instead of inserting data into temporary tables in b,c stored proces, they would insert the data in <strong>tmp</strong> table. To map the rows to specific connection I can add <strong>Group</strong> column and populate it with <strong>@@SPID</strong>. In the end of stored proc <strong>a</strong> I will remove all rows of specific <strong>@@SPID</strong> so it can be used with other connection.
  Is this good and effective solution?</p>
  
  <p>Thank you</p>
  
  <pre><code>create procedure a
  as
  begin try
      declare @tbl table(id int)
      insert into @tbl
      exec b
  end try
  begin catch
  end catch
  
  
  create procedure b
  as
  begin try
      declare @tbl table(id int)
      insert into @tbl
      exec c
  
     select * from @tbl
  end try
  begin catch
  end catch
  
  
  create procedure b
  as
  begin try
      declare @tbl table(id int)
  
      insert into @tbl(id)
      values(1)
  
      select * from @tbl
  end try
  begin catch
  end catch
  </code></pre>
  
  <p>sdfdf</p>