Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 4 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. –  Moo MinTroll Jan 8 '10 at 11:04
add comment

Your Answer

 
discard

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.