Skip to main content

SQL Server: How to Create a Copy of a Table using T-SQL

You can create a copy of your existing table with the help of T-SQL command. For this use “SELECT INTO to extract all the rows from an existing table into the new table. Make sure the new table must not exist already.

SELECT * INTO New_TableName FROM Old_TableName

Example given below will copy the “Product” table to a new table called “Product_Copy”

SELECT * INTO Product_Copy FROM Product

You can also create the new table from a specific subset of columns in the original table. For that, you need to specify the column names to copy instead of “*”. Only specified columns are included in the new table.

SELECT ProductId, ProductName, Description, Price
INTO Product_Copy FROM Product

In above example only ProductId, ProductName, Description and Price columns are copied to “Product_Copy” table.

Comments