2007-11-01

SQL Server: Offline vs DROP DATABASE

If you issue the command DROP DATABASE for a SQL Server database that is offline, the associated MDF and LDF files will not be deleted.

In a related note, if you take a database offline using

sp_dboption 'mydb','offline','true'

you may get this error message when you attempt to bring it online:

Device activation error.  The physical file name 'c:\blah\mydb.ldf' may be incorrect.

Use the following command instead:

alter database mydb set offline with rollback immediate

The former appears does not appear to offline the database files cleanly.