DetachDB Method
Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 않도록 하고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.
The DetachDB method makes a database invisible to an instance of Microsoft SQL Server.
구문
object.DetachDB(DBName [,bCheck ] ) as String
Parts
object
Expression that evaluates to an object in the Applies To list.DBName
String that specifies an existing, attached database by name.bCheck
Optional. When TRUE (default), statistics supporting query optimization are updated prior to the detach operation. When FALSE, statistics are not updated prior to the detach operation.
Prototype (C/C++)
HRESULT DetachDB(SQLDMO_LPCSTR DBName,
SQLDMO_LPBSTR pResult,
BOOL bCheck = TRUE);
Returns
A string containing status or error message detail.
주의
SQL Server implements database detach and attach operations to allow relocation of the operating system files implementing storage for the database and its transaction log. When the database is detached, the files can be moved without negatively affecting an instance of SQL Server.
중요 |
---|
Ensure that bCheck is TRUE when detaching a database for which statistics cannot be updated in the future. For example, databases that will be implemented on read-only media such as CD-ROM should always have query optimization statistics updated as the last step before the detach operations. |
For more information about attaching a detached database by using SQL Distributed Management Objects (SQL-DMO), see AttachDB Method and AttachDBWithSingleFile Method.
Making a database invisible to an instance of SQL Server by using the DetachDB method requires appropriate permission. The SQL Server login used for SQLServer object connection must be a member of the system-defined role sysadmin.