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?

Improve company productivity with a Business Account.Sign Up

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.