Saturday, November 25, 2017

T-SQL Insert Into with CTE

CTE doesn't work with Insert into in nested queries.

With AS has be the first line of query.

and Insert Into can only work if the query finally ends with Insert into clause.

Work around is to split the query in 2 parts.

Where store one set of results in Global temp table.

like

select * into ##ramit from( select * from ----) as temp;

No comments:

Post a Comment