문제

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?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top