In SQL Server Management Studio Object Explorer, connect to an instance of the SQL Server database engine, and then expand the instance.
Expand Databases, and select the name of the user database that you want to detach.
Detaching a database requires exclusive access to the database. If the database is in use, it is limited to allowing only a single user access:
- Right-click the database name and point to properties.
- In the Select a page pane, select Options.
- In the other Options pane, scroll down to the status option.
- Select the restrict Access option, and then, in its drop-down list, select Single User.
- Click OK.
A message box informs you that this operation will close all connections to the database. To continue, click OK.
Right-click the database name, point to Tasks, and then click Detach. The Detach Database dialog box appears.
The database to detach grid displays the name of the selected database in the database name column. Verify that this is the database that you want to detach.
By default, the detach operation retains outdated optimization statistics when the database is detached, and to update existing optimization statistics, select the UPDATE STATISTICS check box.
By default, the detach operation retains all full-text catalogs associated with the database. To remove the full-text catalog, clear The Keep full-text catalog check box.
The Status column displays the current database state (ready or not ready).
If the status is not ready, the message column displays hyperlink information about the database. When the database involves replication,the message column is displayed Database replicated
. When a database has one or more active connections, themessage column displays the number of < active connections > active connections; For example, an active connection. Before you can detach a data column, you must select the delete connection check box to disconnect the connection to all active connections.
To get more information about a message, click the hyperlink.
When you are ready to detach the database, click OK. http://technet.microsoft.com/zh-cn/library/ms191491 (v=sql.90)
How to detach a database (SQL Server Management Studio)