Can use select into with multiple cte? for example in the below code the result of the first cte cte_table is inserted into dbo.table1, then the other cte is defined. is this possible?
WITH cte_table
AS
(
SELECT *
FROM dbo.table
)
INSERT INTO dbo.table1
SELECT *
FROM [cte_table]
, cte_table2
AS
(
SELECT *
FROM dbo.table2
)
If your case is
Re-usabilityof the record set, in that case use a Temp Table or Table variable.e.g.
A chained Cte work as under (just an example)
Hope you understand when to use what and how.