Duplicate Tables

You can duplicate an existing table in SQL Server 2012 by using SQL Server Management Studio or Transact-SQL by creating a new table and then copying column information from an existing table.

Important

This operation duplicates only the structure of a table; it does not duplicate any table rows.

In This Topic

  • Before you begin:

    Security

  • To duplicate a table, using:

    SQL Server Management Studio

    Transact-SQL

Before You Begin

Security

Permissions

Requires CREATE TABLE permission in the destination database.

Arrow icon used with Back to Top link [Top]

Using SQL Server Management Studio

To duplicate a table

  1. Make sure you are connected to the database in which you want to create the table and that the database is selected in Object Explorer.

  2. In Object Explorer, right-click Tables and click New Table.

  3. In Object Explorer right-click the table you want to copy and click Design.

  4. Select the columns in the existing table and, from the Edit menu, click Copy.

  5. Switch back to the new table and select the first row.

  6. From the Edit menu, click Paste.

  7. From the File menu, click Save table name.

  8. In the Choose Name dialog box, type a name for the new table and click OK.

Arrow icon used with Back to Top link [Top]

Using Transact-SQL

To duplicate a table in Query Editor

  1. Make sure you are connected to the database in which you want to create the table and that the database is selected in Object Explorer.

  2. Right-click the table you wish to duplicate, point to Script Table as, then point to CREATE to, and then select New Query Editor Window.

  3. Change the name of the table.

  4. Remove any columns that are not needed in the new table.

  5. Click Execute.

Arrow icon used with Back to Top link [Top]