C# ASP.NET SQL SERVER

Cannot drop database because it is currently in use

I was getting this error when trying to drop a database:
Cannot drop database "MyDatabaseName" because it is currently in use.

I tried the sp_who command to see if there was anything holding on to the DB that I hadn't disconnected from. Couldn't see anything.

drop database MyDatabaseName kept on failing.

Eventually I closed SQL Server Management Studio (SSMS) and reopened it and the drop command then worked immediately. No idea why this happened but this was the solution.

» Similar Posts

  1. LINQ to SQL architecture question
  2. Copy data from local table to remote database table
  3. Deployed ASP.NET MVC app gives 404 on About Page

» Trackbacks & Pingbacks

    No trackbacks yet.
Trackback link for this post:
http://guyellisrocks.com/trackback.ashx?id=40

» Comments

  1. guy ellis avatar

    Happened again and same solution. This time I was trying to restore a DB. So closed SSMS and reopened it and the restore ran straight away. I believe that SSMS had been left open for several days with about 4 query windows open that were being used on an ad hoc basis.

    Running this on Server 2003

    guy ellis — June 27, 2008 12:21 AM
  2. Mark del Campo avatar

    I had the same issue on SQL Server 2005. I couldn't find any open connections to the database. I had left SSMS open for a few days. I closed SSMS and was able to drop the database.

    Thanks for the post

    Mark del Campo — October 24, 2008 4:34 PM

» Leave a Comment