Hi all,
From Page 88 of the book "SQL Programming & Databasze Design Using Microsoft SQL Server 2012", by Kalman Toth, I copied the the following CTE code:
-- CTETest1.sql /// saved in C:\My Documents\SQL Server Management Studio\ ---- 12 March 2015 USE AdventureWorks WITH CTE(SalesPersonID, NumberOfOrders, MostRecentOrderDate) AS ( SELECT SalesPersonID, COUNT(*), CONVERT(date, MAX(OrderDate)) FROM Sales.SalesOrderHeader GROUP BY SalesPersonID ) SELECT * FROM CTE; I executed the code in my SQL Server 2012 Management Studio and I got the following error message:
Msg 319, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. I just starte ...

Go to the complete details ...