SELECT - INTO clause
creates the table and inserts all rows in one statement
What changes
- Input
- the query result
- Output or change
- a new table (created from the select-list shape; can be #temp)
Syntax at a glance
[ INTO new_table ] [ ON filegroup ]
Work example
A one-time analysis needs a new table created from a query result in a disposable database.
Use an isolated target. Review inferred column types and add required keys, indexes, constraints, and permissions separately.
Check your work SELECT - INTO clause. The new table has the intended rows and schema. No production object is targeted.
Open Microsoft Learn for full syntax, permissions, and details for your version.