sqlsql-servert-sqlssms

Duplicating a TABLE using Microsoft SQL Server Management


Need to duplicate a TABLE using Microsoft SQL Management Studio 2008

The TABLE needs to duplicate all table row (Primary Key) ID as well.


Solution

  • In SSMS open a new query window and then do something like this:

    SELECT * INTO NewTable
    FROM OldTable
    

    Change NewTable to the name that the new table should have. Change OldTable to the name of the current table.

    This will copy over the basic table structure and all the data. It will NOT duplicate any of the table constraints; you will need to script those out and change the names in those scripts.