title: SQL Server : Insert stored procedure results into table based on parameters
body: <p>I have a stored procedure <code>Test_Sp</code> which returns data in this way:</p>
  
  <pre><code> Id  Name     Age   Address  State  Country
   1   ManiS    25     aaaa     bbb     ccc
  </code></pre>
  
  <p>This stored procedure is returning 6 columns of data, but I want to insert only the first 2 columns into a temp table..</p>
  
  <p>My temp table variable is:</p>
  
  <pre><code>Declare @testTbl Table (RowId int identity, Name nvarchar(100), Age int);
  INSERT INTO @testTbl(Name,Age) EXEC [Test_Sp] 23;
  Select * from @testTbl;
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>Msg 50000, Level 16, State 0, Procedure Test_Sp, Line 16<br>
    Cannot use the ROLLBACK statement within an INSERT-EXEC statement.</p>
  </blockquote>
  
  <p>I am aware about <code>Select * into</code> &amp; if I create a temp table with same columns as stored procedure output means it will work..</p>
  
  <p>My question: is it possible to insert just two columns into a temp table variable from the stored procedure output based on parameters?</p>