title: Avoiding "An INSERT EXEC statement cannot be nested"
body: <p>I know that this is not possible to nest <code>insert ... exec</code> statements, but still I'm interested - is there a way to check if I already have active <code>insert ... exec</code> to avoid actual error?</p>
  
  <p>So I want to have something like this:</p>
  
  <pre><code>....
  if &lt;check if I have outer insert into exec&gt; = 0
      insert into &lt;#some temporary table&gt;
      exec &lt;stored procedure&gt;
  </code></pre>
  
  <p>In other words - <code>insert ... exec</code> is optional, it's nice to have it, but I want to skip it if somebody tries to call my procedure with outer <code>insert ... exec</code></p>