select and insert into tempdb table code example
Example: select into temp table
SELECT *
INTO #temp
FROM (
SELECT col1, col2
FROM table1
) AS x
SELECT *
INTO #temp
FROM (
SELECT col1, col2
FROM table1
) AS x