title: How to save stored procedure output into table
body: <p>I am new to T-SQL so I apologize if I am stating my question wrong.</p>
  
  <p>I have a SQL Server stored procedure that has properties and returns integer value also selects some columns from different tables. </p>
  
  <p>I was wondering how can I store that result into regular table</p>
  
  <pre><code>DECLARE @prop1 int;
  DECLARE @prop2 int;
  DECLARE @result int;
  
  set @prop1 = 2
  set @prop2 = 5
  
  exec @result = dbo.Proc1 @prop1    @prop2
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>id    name      value
  ---------------------
  1     Example     6
  2     Process     8
  ..    ........    ..
  </code></pre>
  
  <p>Thank you in advance for all your input.</p>
  
  <p>//-----------Edit 04/22/2015---------------------------</p>
  
  <p>I am trying to use T-SQL below: </p>
  
  <pre><code>  SELECT * INTO Tx.ReportFacts FROM OPENROWSET('SQLNCLI',   'Server=GCA_A;Trusted_Connection=yes;',
     'SET NOCOUNT ON;SET FMTONLY OFF; EXEC @RC =   ReportLibrary.Rpt.Server_GetAllDiscrepancies @FacilityKey ,@StationKeys  ,@MedItemKeys ,@MedClassCodes ,@UserAccountKeys ,@ResolutionStatus  ,@TransactionLimit ,@ReportStartDate ,@ReportEndDate')
    -- Select Table
    SELECT *
    FROM Tx.ReportFacts;
  </code></pre>
  
  <p>But getting error below: </p>
  
  <pre><code>OLE DB provider "SQLNCLI11" for linked server "(null)" returned message "Deferred prepare could not be completed.".
  Msg 8180, Level 16, State 1, Line 1
  Statement(s) could not be prepared.
  Msg 137, Level 15, State 2, Line 1
  Must declare the scalar variable "@RC".
  </code></pre>
  
  <p>Can anyone point out why this is happening. And what is wrong with my T-SQL statement?</p>