title: Table variable poor performance on insert in SQL Server Stored Procedure
body: <p>We are experiencing performance problems using a table variable in a Stored Procedure.</p>
  
  <p>Here is what actually happens :</p>
  
  <pre><code>DECLARE @tblTemp TABLE(iId_company INT)
  
  INSERT INTO @tblTemp(iId_company)
    SELECT id FROM .....
  </code></pre>
  
  <p>The SELECT returns 138 results, but inserting in the TABLE variable takes 1min15 but when I use a temp table with the same SELECT, woops, takes 0sec :</p>
  
  <pre><code>CREATE TABLE #temp (iId_company INT)
  
  INSERT INTO #temp(iId_company)
    SELECT id FROM ...
  </code></pre>
  
  <p>What could cause the behavior ?</p>