title: Select only few columns from procedure and insert into table
body: <p>I have a stored procedure that returns 6 columns. But I want to take only 2 columns and insert them into my table variable. </p>
  
  <pre><code>DECLARE @CategoryTable TABLE(   
  CategoryId Int NOT NULL,   
  Name nvarchar(255) NOT NULL   
  )  
  
  INSERT INTO @CategoryTable EXEC [GetAllTenantCategories] @TenantId  
  </code></pre>
  
  <p>When I run this </p>
  
  <blockquote>
    <p>Column name or number of supplied values does not match table
    definition</p>
  </blockquote>
  
  <p><strong>How to insert only specified columns from a stored procedure?</strong> </p>
  
  <p>I do not want to use <code>SELECT INTO</code> as it is not supported by SQL Azure</p>
  
  <p>Tried below and got <code>Invalid object name '#Temp'</code></p>
  
  <pre><code>DECLARE @CategoryTable TABLE(   
  CategoryId Int NOT NULL,   
  Name nvarchar(255) NOT NULL   
  )  
  INSERT INTO #Temp EXEC [GetAllTenantCategories] 1 
  
  INSERT INTO @CategoryTable (CategoryId, Name) 
  SELECT CategoryId, Name from #Temp
  
  DROP TABLE #Temp
  </code></pre>