SQL SELECT INTO Statement
The SQL SELECT INTO Statement
The SELECT INTO statement copies data from one table into a new table.
SELECT INTO Syntax
Copy all columns into a new table:
Copy only some columns into a new table:
The new table will be created with the column-names and types as defined in the old table. You can create new column names using the AS clause.
SQL SELECT INTO Examples
The following SQL statement creates a backup copy of Customers:
The following SQL statement uses the IN clause to copy the table into a new table in another database:
The following SQL statement copies only a few columns into a new table:
The following SQL statement copies only the German customers into a new table:
Tip: SELECT INTO can also be used to create a new, empty table using the schema of another. Just add a WHERE clause that causes the query to return no data:
Last updated