SQL creating a temp tabele using a select into code example
Example 1: select into temp table
SELECT t.col1, t.col2...
INTO #temp
FROM table1 AS t
Example 2: select into temp table
SELECT *
INTO #temp
FROM (
SELECT col1, col2
FROM table1
) AS x