With as in a view

I am able to use one with as in  a view in sql server 2008 but get an error if I try to use more than one

is there a way to use more than one?
johnnyg123Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
lluddenConnect With a Mentor Commented:
Separate them with commas, not new WITH statements.

CREATE VIEW V1 AS 
WITH ct1 AS (SELECT * FROM myTable WHERE ID = 2),
ct2 AS (SELECT * FROM MyTable where ID = 3)
SELECT * FROM ct2 INNER JOIN Ct2 ON ct1.Name = Ct2.Name

Open in new window

0
 
johnnyg123Author Commented:
Great thanks!
0
All Courses

From novice to tech pro — start learning today.