How to delete (localdb) database if the file is gone

Bob.at.Indigo.Health picture Bob.at.Indigo.Health · Nov 16, 2012 · Viewed 19.1k times · Source

If I run SQL Server Management Studio, and tell it to connect to (localdb)\v11.0, it knows about every database I've ever used, despite the fact that most of the the database files are long gone.

If I ask it to delete one of these databases, it complains that it can't DROP the database because the database file is gone (duhhh). So, how do I clean up this mess and delete all of database references whose assicated database files are gone?

Bob

Answer

IRM picture IRM · Dec 2, 2012

In this situation, detach the database rather than trying to drop it. In SQL Management Studio, right-click on the database, select "Tasks" then "Detach".