laika222
6/19/2017 - 8:18 PM

Copy Table Using SELECT * INTO or SELECT INTO.sql

-- you can copy rows from one table to another using SELECT INTO. This copies the rows but does not copy things like keys, so you'll have to add that in as a second step if you wish to have them.

-- how to copy all rows and columns from one table into a new table
SELECT * INTO customersNew FROM customersOld;

-- how to copy all columns but only certain rows from one table into a new table
SELECT * INTO customersNew FROM customersOld
WHERE CustomerID = 3;

-- how to copy only certain columns from one table into a new table
SELECT CustomerID, LastName, FirstName INTO customersNew FROM customersOld;