title: Dynamically query a temp table created in a stored procedure
body: <p>I've created a stored procedure that creates a temp table. Now I need to be able to query over it using .NET. So I would need something like:</p>
  
  <pre><code>SELECT * FROM storedProcedure() WHERE ...
  </code></pre>
  
  <p>The table created by the stored procedure is dynamic as well so the schema will change. Using SQL Server 2005.</p>
  
  <p>I cant use a function because what needs to be returned is a dynamic table. Having to define the table beforehand makes a function useless. </p>
  
  <p>I ended up creating a global temp table with the help of dynamic SQL I was able to create a dynamic global temp table and access it via .NET.</p>