3

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?

1
  • yes! this is a feature!! Jan 11, 2010 at 15:03

1 Answer 1

8

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.

3
  • 1
    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, 2010 at 10:19
  • 1
    So after kicking out all users by setting to offline, I should probably take it back online again before dropping it.
    – Ries
    Jan 8, 2010 at 10:20
  • 1
    You could also use SET SINGLE_USER or RESTRICTED_USER so you don't have to take the database offline. Jan 8, 2010 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .