title: Using the WITH clause in an INSERT statement
body: <p>I was wondering if this was possible. I have an existing query that uses the <code>WITH</code> clause to apply some aggregated data to a <code>SELECT</code> query like so: (massively simplified)</p>
  <pre><code>;WITH alias (y,z)
  AS
  (
      SELECT y,z FROM tableb
  )
  SELECT y, z FROM alias
  </code></pre>
  <p>I now want to <code>INSERT</code> the results of this query into another table.</p>
  <p>I have tried the following:</p>
  <pre><code>INSERT INTO tablea(a,b)
  ;WITH alias (y,z)
  AS
  (
      SELECT y,z FROM tableb
  )
  SELECT y, z FROM alias
  </code></pre>
  <p>but I get the error:</p>
  <blockquote>
  <p>Incorrect syntax near ';'.</p>
  </blockquote>
  <p>So I have tried without the semicolon but got the error:</p>
  <blockquote>
  <p>Incorrect syntax near the keyword 'WITH'.</p>
  <p>Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.</p>
  </blockquote>
  <p>Is what I am trying to do possible with different some different syntax?</p>