Detaches a database from a server and, optionally, runs UPDATE STATISTICS on all tables before detaching.
sp_detach_db [@dbname =] 'dbname'
[, [@skipchecks =] 'skipchecks']
0 (success) or 1 (failure)
None
The detached files remain and can be reattached using sp_attach_db or sp_attach_single_file_db. The files can also be moved to another server and attached.
Only members of the sysadmin fixed server role can execute sp_detach_db.
This example detaches the pubs database with skipchecks set to true.
EXEC sp_detach_db 'pubs', 'true'
sp_attach_db | sp_attach_single_file_db |