How to Copy a Table in SQL Server

SQL Server

Making a copy of the data in one table into a new table is a basic part of what a Database Administrator (DBA) may be asked to do as part of their normal responsibilities. One of the easiest ways to do that is:

SELECT * INTO MYTABLE_BACKUP FROM MYTABLE

This will create a new table and copy the data into the new table. The new table is named MYTABLE_BACKUP, and will contain the same rows as the original MYTABLE table. Another request might be to copy the table, without copying the data:

SELECT * INTO MYTABLE_BACKUP FROM MYTABLE WHERE 1 = 0;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s