Msg 319, Level 15, State 1, Line 3
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.
This error message appears when you try to use a common table expression or an xmlnamespace clause, but the previous statement has not been terminated by a semicolon.
The SQL statement cannot be parsed and further execution is stopped.
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user. The statement can not be run this way. You either must terminate the previous statement with a semicolon or begin the common table expression with a semicolon.
This error message was introduced with SQL Server 2005.
SELECT * FROM (SELECT 1 UNION ALL SELECT 2) x (c1)
SELECT * FROM myCte
In the above example we try to use the common table expression myCte. Because the previous statement has not been terminated with a semicolon, the error is raised.
It is considered best practise to terminate all statements with a semicolon.]]>