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 ')'.
you can do it as follows:
; with res1 as (
select 1 as col1
),
res2 as(
select * from res1
)
select * from res2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With