f2s_mssql_detach_db¶
Applies to: MS SQL
Syntax
f2s_mssql_detach_db {database}
Parameter |
Description |
---|---|
database |
Name of the database to detach |
Description
The f2s_mssql_detach_db command will detach a local SQL Server database. When using LocalDB’s a common use case might be to attach to a customer DB, do some work on it, and then detach this DB and attach to a different DB. This was possible using stored procedures, but the code had some complexities that a developer need not worry about. A detach can only be done if the database passed has no open connections. As part of the detach process, the command closes ALL open files (even those not associated with this database or driver).
NOTE: f2s_mssql_detach_db will often fail to execute if you are testing your application from the studio. This is because the studio itself normally has open connections to the database. If you test your application outside of the studio and the studio is closed (and any other application or tools that access this database are closed) you can successfully detach the database.
Example
f2s_mssql_detach_db "MTSample"
Related Commands
f2s_mssql_attach_db
Replaces: SQLSERVER_DETACH_DB