How to attach and detach a database (Enterprise Manager)

How to Install SQL Server 2000

How To

How to attach and detach a database (Enterprise Manager)

To attach a database

  1. Expand a server group, and then expand a server.

  2. Right-click Databases, and select All Tasks/Attach Database.

  3. Enter the name of the MDF (master data file) of the database to attach. If you are not sure where the file is located, click browse (...) to search. There can only be up to 16 file names specified. For more information, see sp_attach_db.

  4. To ensure that the specified MDF file is correct, click Verify. The Original File Name(s) column lists all the files in the database (data files and log files). The Current File(s) Location column lists the file names and paths. If Microsoft® SQL Server™ cannot find the files in the specified locations, the attach operation fails. The Current File(s) Location column can be edited, and the current location of the file must be in this column for the attach operation to work. For example, if you have changed the default location of the file before you detached it, you must specify the current location for the attach operation to be successful.

  5. In the Attach as box, enter the name of the database. The database name must not match any existing database names.

  6. Specify the database owner.

  7. Click OK. A database node for the newly attached database is created in the Database folder.

To detach a database

  1. Expand a server group, and then expand a server.

  2. Expand Databases.

  3. Right-click the database, and then select All Tasks/Detach Database. This menu is visible only if you are a member of the sysadmin fixed server role and the server to which you are connected is SQL Server 2000. The master, model, and tempdb databases cannot be detached.

  4. In the Detach Database dialog box, check the status of the database. To successfully detach a database, STATUS should be: The database is ready to be detached. Optionally, you can select to update statistics prior to the detach operation.

  5. To terminate any existing connections from the database, click Clear.

  6. Click OK. The database node for the detached database is removed from the Database folder.