SELECT INTO is used to insert selected data into a new database (even a temp one.) Let’s say…
1 2 3 4 5 6 7 8 9 10 |
CREATE TABLE #temp ( NUMBER INT, NAME VARCHAR(1) ) INSERT INTO #temp VALUES (1,'a'), (1,'a'), (1,'b'),(2,'a'), (2,'b'),(2,'b'), (1,'c'),(2,'c') |
Then…
1 2 3 4 5 6 |
SELECT * INTO #temp2 FROM #temp SELECT * FROM #temp2 |
1 2 3 4 5 6 7 8 9 |
NUMBER NAME 1 a 1 a 1 b 2 a 2 b 2 b 1 c 2 c |