You can detach a database that is currently not in use. Detaching a database removes it from the instance of the Microsoft SQL Server Database Engine but leaves intact the database, with its data files and transaction log files. These files can then be used to attach the database to any instance of SQL Server, including the server from which the database was detached. You cannot detach a database if any of the following are true:
- The database is replicated and published. If replicated, the database must be unpublished.
- A database snapshot exists on the database.
- The database is being mirrored in a database mirroring session. The database cannot be detached unless the session is terminated.
Note: After detaching a SQL Server database, you can reattach it to the same or another instance of SQL Server. For more information, see Attach a Database
To detach a database
- Connect to an instance of the Microsoft SQL Server Database Engine in the SQL Server Management Studio Object Explorer.
- Expand the instance.
- Expand Databases and select the name of the user database that you want to detach.
Note: Detaching a database requires exclusive access to the database. If the database is in use, restrict access to a single user.
- Right-click database name and click Tasks, Detach.
The Detach Database dialog opens with the name of the selected database in the Database Name column of the Databases to detach grid.
- Verify the selected database is that you want to detach.
- Click the Update Statistics check box.
The existing optimization statistics is updated.
Note: By default, the detach operation retains any out-of-date optimization statistics when detaching the database.
- Clear the Keep Full-Text Catalogs check box.
The full-text catalogs that are associated with a database is removed.
Note: By default, the detach operation keeps any full-text catalogs that are associated with the database.
- Select the Drop Connections check box.
All the active connections are disconnected.
Note: The Status column displays the current database state (either Ready or Not Ready).
- The Message column displays information about the database in a hyperlink, if the status is Not Ready. Click the hyperlink, to obtain more information about a message.
- The Message column displays Database replicated, when a database is involved with replication.
- The Message column displays <number_of_active_connections> Active connections, when a database has one or more active connections.
- Click OK.
The database is now detached.
Note: The newly detached database will remain visible in the Databases node of Object Explorer until the view is refreshed. You can refresh the view at any time.
After detaching the CASRMCentralDB, copy the CASRMCentralDB MDF, LDF files from the default location and paste them into another partition where we have more space allocated.
Copy the mdf and ldf files from default location C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\CASRMCentralDB.mdf to D:\SQLDataFiles