Code has been added to clipboard!

Using SQL SELECT INTO

Reading time 1 min
Published Aug 9, 2017
Updated Oct 9, 2019

TL;DR – You can use SQL SELECT INTO to duplicate information from one table to another. It can also produce a unique table which is then placed in a file group. The new table cannot be defined as a table variable.

The syntax for SQL SELECT INTO

Copying all columns to a table

Example
SELECT *
INTO ntable [IN edb]
FROM otable
WHERE condition;

Note: The names/types are described in SELECT. New names can be assigned using the AS clause.

Copying particular columns to a table

Example
SELECT column1, column2, column3, ...
INTO ntable [IN edb]
FROM otable
WHERE condition;

SQL SELECT INTO usage examples

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Backing up a table

Example
SELECT * INTO CustomerBackup2018
FROM Customers;

Copying a table to other database

Example
SELECT Name, Contact INTO CustomerBackup2017
FROM Customers;

Only copying a few columns

Example
SELECT * INTO CustomerBackup2017 IN 'Backup.mdb'
FROM Customers;

Only copying entries from a single country

Example
SELECT * INTO CustomerGermany
FROM Customers
WHERE Country = 'Germany';

Copying multiple tables into a new one

Example
SELECT Customers.Name, Customer_orders.ID
INTO CustomerOrderBackup2017
FROM Customers
LEFT JOIN Order ON Customers.ID = Customer_orders.Customer_id;

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 02/03/2021
3176 People Used
Only 97 Left
Rating
5.0