Frage

I have created 3 tables using CTE as follows:

;WITH Temp1(...)
AS
(...), Temp2
AS
(...), Temp3
AS
(...)
select * from Temp3;

I am curious about their existence in memory (or somewhere?), are Temp1 and Temp2 still in memory after Temp3 was created?

War es hilfreich?

Lösung

They all exist within the scope of the with statement. You can easily prove this by selecting from them.

;with 
    temp1 as (...),
    temp2 as (select * from temp1),
    temp3 as (...)
select * from temp1 
union 
select * from temp2
union 
select * from temp3
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top