title: Export/View data from a SQL Server temporary table
body: <p>I have a temporary table, that isn't going away.  I want to see what is in the table to determine what bad data might be in there.  How can I view the data in the temporary table?</p>
  
  <p>I can see it in <code>tempdb</code>.  I ran </p>
  
  <pre><code>SELECT * FROM tempdb.dbo.sysobjects WHERE Name LIKE '#Return_Records%'
  </code></pre>
  
  <p>to get the name of the table.</p>
  
  <p>I can see it's columns and its object id in </p>
  
  <pre><code>select c.*
  from tempdb.sys.columns c
  inner join tempdb.sys.tables t ON c.object_id = t.object_id
  where t.name like '#Return_Records%'
  </code></pre>
  
  <p>How can I get at the data?</p>
  
  <p>By the way, this doesn't work </p>
  
  <pre><code>SELECT * FROM #Return_Records 
  </code></pre>