Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

SELECT INTO

SELECT INTO

The SELECT INTO command duplicates data from one table and inserts it into a new table.

The subsequent SQL statement creates a backup copy of Customers:

SELECT * INTO CustomersBackup2017
FROM Customers; 

The provided SQL statement utilizes the IN clause to duplicate the table into a new table in another database:

SELECT * INTO CustomersBackup2017 IN ‘Backup.mdb’
FROM Customers; 

The subsequent SQL statement copies only selected columns into a new table:

SELECT CustomerName, ContactName INTO CustomersBackup2017
FROM Customers; 

The provided SQL statement duplicates only the German customers into a new table:

SELECT * INTO CustomersGermany
FROM Customers
WHERE Country = ‘Germany’

The following SQL statement duplicates data from multiple tables into a new table:

SELECT Customers.CustomerName, Orders.OrderID
INTO CustomersOrderBackup2017
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;