title: How to save a queried CTE output into a temporary table or table variable
body: <p>I have a <code>CTE</code> and query this one</p>
  
  <pre><code>;With CTE_Table as (SELECT ...)
  Select * from CTE_Table
  </code></pre>
  
  <p>Now I try to save this result into a <code>table variable</code> or <code>temporary table</code>. If I try</p>
  
  <pre><code>Declare @Table table
  (...)
  INSERT INTO @Table (...)
  HER I PUT THE CODE ABOVE
  </code></pre>
  
  <p>I get an <code>incorrect syntax error</code> around the <code>WITH</code> statement. I guess the <code>Insert Into</code> command expects a <code>Select statement</code> instead of a <code>;WITH</code> and the same goes for <code>Create Table</code>. I was looking for solutions but all <a href="https://social.msdn.microsoft.com/forums/sqlserver/en-US/63725d14-8e59-4009-b1da-c28f96f98d8e/using-a-cte-then-getting-results-into-a-temp-table" rel="nofollow">I found</a> did not involve the <code>Select Statement</code> after the <code>;With</code>. How do I get the output shown above into a <code>temporary table</code> or <code>table variable</code>? </p>
  
  <p>I use SQL Server 2014.</p>