Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When my colleague drops a database he just created on SQL 2008 Express using Management Studio 2008 the files do not get deleted.

When I drop a database I just created on SQL 2005 Express using Management Studio 2008 the files do get deleted.

If my uninstaller executes a DROP DATABASE query on the same 2005 database then the files do not get deleted.

Is there a setting that determines if files will be deleted or what is going on?

share|improve this question
yes! this is a feature!! – Nick Kavadias Jan 11 '10 at 15:03
up vote 7 down vote accepted

How does your colleague drop the database? If he is detaching them, then they won't get deleted - perhaps he's doing that? Alternatively, if the database is offline when it's deleted then the data files do not get deleted. See DROP DATABASE for more information on this.

share|improve this answer
This makes sense as my uninstaller's query to drop the database looks like this: "ALTER DATABASE " + dbName + " SET OFFLINE WITH ROLLBACK IMMEDIATE; DROP DATABASE " + dbName; – Ries Jan 8 '10 at 10:19
So after kicking out all users by setting to offline, I should probably take it back online again before dropping it. – Ries Jan 8 '10 at 10:20
You could also use SET SINGLE_USER or RESTRICTED_USER so you don't have to take the database offline. – Mark Allison Jan 8 '10 at 11:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.