title: Temp table in Azure SQL Server returns error on second insert in Stored Procedure
body: <p>I have a temp table declared in a stored procedure within an Azure SQL Server instance.</p>
  
  <p>After declaring it with</p>
  
  <pre><code>WITH temp 
      (cols) AS 
      (SELECT * FROM goaltable 
      WHERE someCondition = true)
  </code></pre>
  
  <p>and utilizing it in a couple of <code>INSERT</code> statements, SQL Server returns an error on the second <code>INSERT</code> that <code>invalid object name 'temp'.</code></p>
  
  <p>Will I have to declare the table again before my second <code>INSERT</code> statement, or is there a better way to do it?</p>