title: Cant define SQL variable when using WITH statement
body: <p>This sql is valid:</p>
  
  <pre><code> WITH A AS
   (SELECT TOP 1000 * 
    FROM dbo.SomeTable)
  
   SELECT * FROM A
  </code></pre>
  
  <p>While this one gives an error(<em>Incorrect syntax near the keyword 'DECLARE'</em>):</p>
  
  <pre><code>WITH A AS
  (SELECT TOP 1000 * 
   FROM dbo.SomeTable)
  
   DECLARE @dt DATETIME 
  
   SET @dt = GETDATE()
   SELECT * FROM A
  
   PRINT DATEDIFF(SS,GETDATE(),@dt)
  </code></pre>
  
  <p>Why?</p>