title: Use nested stored procedure results in calling stored procedure Sql Server 2008
body: <p>Is it possible to use the results of one stored procedure in another stored procedure?</p>
  
  <p>I.e.</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[Proc1]
          @ID INT,
          @mfgID INT,
          @DealerID INT
  
  AS
  BEGIN
  
      DECLARE @Proc1Result UserDefinedTableVariable
  
      EXEC @Proc1Result = Proc2
          @SomeID = @ID,
          @SomeID2 = @mfgID,
          @SomeID3 = @DealerID
  
      -- Now I want to use the table returned by the stored procedure here.
      SELECT [col1],[col2] FROM @Proc1Result
  
  END
  </code></pre>
  
  <p>I tried using <code>INSERT INTO @Proc1Result EXEC Proc2 (with parameters passed)</code>, but <code>INSERT EXEC</code> cannot be called in a nested statement.</p>
  
  <p>Is there any way of accomplishing this? The environment is SQL Server 2008.</p>