Incorrect syntax near the keyword 'with'...previous statement must be terminated with a semicolon
Use a comma to separate CTEs
;WITH SomeClause1 AS
(
SELECT ....
)
, SomeClause2 AS
(
SELECT ....
)
Forget about adding a ";" to the previous statement, like the error message says. Just get in the habit of always coding it like: ";WITH" and you'll be fine...
;WITH SomeClause1 AS
(
SELECT ....
)
however, you must connect multiple CTEs with commas, but the ";WITH" always has a semicolon before it:
;WITH SomeClause1 AS
(
SELECT ....
)
,SomeClause2 AS
(
SELECT ....
)