title: Error: An INSERT EXEC statement cannot be nested insert in a temp table with SP recursively
body: <p>I am trying to achieve this</p>
  
  <pre><code>WHILE @@FETCH_STATUS = 0
  BEGIN
      INSERT INTO #TRSupervisors
        EXEC [stpEmployee_getExpiryDateSupervisors] '0000912479', '100', @TRplant, 'ILOD', 1, 0
      FETCH NEXT FROM TRcurPlant INTO @TRplant
  END
  </code></pre>
  
  <p>On execution I am getting error message which says.</p>
  
  <blockquote>
    <p>Msg 8164, Level 16, State 1, Procedure stpEmployee_getExpiryDateSupervisors, Line 87<br>
    An INSERT EXEC statement cannot be nested.</p>
  </blockquote>
  
  <p>If I execute it without insert statement, like this:</p>
  
  <pre><code>WHILE @@FETCH_STATUS = 0
  BEGIN
      --insert into #TRSupervisors
      EXEC [stpEmployee_getExpiryDateSupervisors] '0000912479', '100', @TRplant, 'ILOD', 1, 0
      FETCH NEXT FROM TRcurPlant INTO @TRplant
  END
  </code></pre>
  
  <p>I'm able to get the desired output.</p>
  
  <p>Please suggest a way to save the output into a temp table.</p>