title: Sql Server CTE syntax error... help, please?
body: <p>just getting my feet wet with sql server express. I have what would be a fairly complicated couple of subqueries, and I simplified it/ them with a cte. I get the error "Incorrect syntax near 'DatesNotNeeded.' Any takers? Thanks in advance...</p>
  
  <pre><code>WITH Symb AS
  (
       SELECT Symbol
       FROM tblSymbolsMain
  ),
  
  DatesNotNeeded AS
  (
       SELECT Date
       FROM tblDailyPricingAndVol
       WHERE (tblDailyPricingAndVol.Symbol = Symb.Symbol)
  ),
  
  WideDateRange AS
  (
       SELECT TradingDate
       FROM tblTradingDays
       WHERE (TradingDate &gt;= dbo.NextAvailableDataDownloadDateTime()) AND (TradingDate &lt;= dbo.LatestAvailableDataDownloadDateTime())
  ),
  
  DatesNeeded AS
  (
       SELECT TradingDate
       FROM WideDateRange
       WHERE NOT EXISTS (DatesNotNeeded)
  ),
  
  SELECT Symb.Symbol, DatesNeeded.TradingDate
  FROM Symb CROSS JOIN DatesNeeded
  </code></pre>