title: What's the difference between a temp table and table variable in SQL Server?
body: <p>In SQL Server 2005, we can create temp tables one of two ways:</p>
  
  <pre><code>declare @tmp table (Col1 int, Col2 int);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>create table #tmp (Col1 int, Col2 int);
  </code></pre>
  
  <p>What are the differences between these two?  I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory.  </p>
  
  <p>In which scenarios does one out-perform the other? </p>