Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect syntax near the keyword 'with'...previous statement must be terminated with a semicolon

Im using SQL Server 2005 . I have 2 WITH Clauses in my stored procedure

WITH SomeClause1 AS (   SELECT .... ) WITH SomeClause2 AS (   SELECT .... ) 

But the error occurs

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.

What are my options? Is there any splitter I don't know about?

like image 607
Duncan Avatar asked Sep 17 '09 14:09

Duncan


1 Answers

Use a comma to separate CTEs

;WITH SomeClause1 AS (   SELECT .... ) , SomeClause2 AS (   SELECT .... ) 
like image 119
gbn Avatar answered Sep 24 '22 12:09

gbn