Wachburn
Wachburn

Reputation: 2939

Difference between [detach] and [set offline and drop database]

MSDN says "If the database or any one of its files is offline when it is dropped, the disk files are not deleted". So if I first set database offline and then drop it

alter database newbase set offline
drop database newbase

The database files will remain on the disk and then they can be attached again. So, what is the difference, if I detach instead

exec sp_detach_db @dbname='newbase'

Upvotes: 2

Views: 3350

Answers (1)

Rhys Jones
Rhys Jones

Reputation: 5508

See Dropping an Offline Database in SQL Server by Kendra Little. In summary, the offline/drop behaviour is by design, and although the 2 approaches are technically different (different processes and different actions logged) the nett effect is the same.

Upvotes: 1

Related Questions