That works:
; with res1 as (
select 1 as col1
)
select * from res1
How to nest a WITH statement one inside another? I tried
; with res1 as (
; with res2 as (
select 1 as col1
)
select * from res2
)
select * from res1
but I get an error:
Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ';'. Msg 102, Level 15, State 1, Line 6 Incorrect syntax near ')'.