All Collections
Administrators
Installation & Maintenance
Moving a Database Using the Detach/Attach Method
Moving a Database Using the Detach/Attach Method
D
Written by Don
Updated over a week ago

INFORMATION


In some situations it may be necessary to move the database files to a new location on the same server. Microsoft SQL Server supports the ability to detach a database from SQL Server, move the files and attach the database in its new location.

To move a database using detach/attach:

NOTE: All database connections must be stopped before making any of the changes below. Disconnect any connections being made to your database.

  1. Open the SQL Enterprise Manager (SQL 2000) or SQL Management Studio (SQL 2005).
    NOTE: Make a complete backup of the database before making any changes to your system.

  2. Locate the desired database and right-click. Choose Detach Database from the All Tasks submenu.

  3. Locate the database files for the now detached database. Copy the files to the new location. Do NOT move the files because data can be lost if the move operation fails.

  4. In the SQL Enterprise Manager or Management Studio, right-click databases and choose Attach Database from the All Tasks submenu.

  5. Locate the database .mdf file from the file system.
    If everything is correct, Microsoft SQL Server should locate the corresponding database .ldf file.

  6. Re-connect to your database via Workgroups by restarting the MetaCommunications Application Server service.

Did this answer your question?