Copy & Rename Database Procedures

Back Home Up Next


NOTE:  Most/many of these procedures are still relevant,
but this page was created in the SQL Server 2000 era!

Task:

Method:

Limitation(s):

Duplicate a database with:

Copy Database Wizard

Start by clicking on the Wizards toolbar button, then Management, then Copy Database Wizard,
or,
 

Source & Destination Server cannot be the same server.

Destination server cannot have a DB with the same name as the source.

[Double check] Does not create constraints at the destination

Copy Databases and Database Objects:

DTS Transfer Databases Task

 

Copies or Moves one or more selected databases to a destination.

From BOL: "The Transfer Database Objects tasks are custom tasks used by the Copy Database Wizard..."

Copy Tables & Views:

DTS Import/Export Wizard

 

Use a Query to Specify the Data to Transfer

Copy Objects & Data between SQL Server Databases (same instance)

Copy Tables & Views...

Use a Query to Specify...

Copy Objects & Data...will permit copying to the same or different SQL instance or SQL Server but you must create a new DB on the fly; this also recreates all constraints!

 

Move and/or Rename Database files to the same or different server or instance:

Detach/Re-attach DB
 

Use Enterprise Manager,

or,

System-Stored Procedure

Enterprise Manager...this retains constraints, database users, and a database diagram

System-Stored Procedure...sp_detach_db and sp_attach_db

After the database is detached, you can attach the DB to a new or same destination.

Relocate a Database:

Backup/Restore

After a database is backed up to a file or device, you can attach the DB to a new destination.

 

Rename a Database:

sp_renameDB 'oldname', 'newname'