Pergunta

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?

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top