Question

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?

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top