Why is SQL Server 2005 hanging up when I try to delete a database?

I've got a Windows 2003 server with SQL Server 2005 and when I log into the Management Studio, right-click on a Database and choose "Delete" I get the Delete Object dialogue. I then click OK at the bottom and it grays out the dialogue and shows a spinning indicator but doesn't finish. I've let it run for 5 or 10 minutes and it seems to eat up the CPU, but not do anything. The database I'm trying to delete is very small (a few tables with maybe 1-3 mb of data). Any ideas?


Solution 1:

When you drop the database the UI is going to also try and delete the backup and restore history for the database from the MSDB database. Dry using the DROP DATABASE statement from a query window, then clean up the database backup history manually.

Solution 2:

you can also use this command:

ALTER DATABASE [foo] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

GO

DROP DATABASE [foo];

GO

Where foo is the db name