English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and examples of SQL SELECT INTO keyword

SQL Keyword Reference

SELECT INTO

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

The following SQL statement creates a backup copy of the customers:

SELECT * INTO CustomersBackup2017
FROM Customers;

The following SQL statement uses the IN clause to copy the table to a new table in another database:

SELECT *
INTO CustomersBackup2017 IN 'Backup.mdb'
FROM Customers;

The following SQL statement only copies a few columns to a new table:

SELECT CustomerName, ContactName INTO CustomersBackup2017
FROM Customers;

The following SQL statement copies only German customers to a new table:

SELECT *
INTO CustomersGermany
FROM Customers
WHERE Country = 'Germany';

The following SQL statement copies data from multiple tables to a new table:

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

SQL Keyword Reference