Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove deleted databases from SSMS?

I have a similar problem to this one here : How to remove a list of accidently deleted databases from Sql Server Management Studio's tree-like list? but the provided solution to that question hasn't helped me.

I have a number of database .mdf files that were created (and subsequently deleted from the folder) by VS's web testing.

My SSMS is now chock full of .mdf database files that no longer exist that I can't get rid of.

List of mdf files

Current things I have tried (to no avail):
1. Refreshing the databases (at every level of the tree)
2. Right-click and deleting the databases. I receive the error:
SQLServer error message
3. Recreating the file in the given folder structure (Still doesn't recognise it)

If possible I'd like to avoid having to completely reinstall SS all over again.

like image 785
Danny Avatar asked Mar 13 '17 09:03

Danny


People also ask

How do I revert deleted data in SSMS?

If you? ve the Full database backup available, you can try recovering deleted records using the transaction log with Log Sequence Number (LSN). If the backup is corrupted, use Stellar Repair for MS SQL to recover the deleted data in SQL Server or in other formats like Comma Separated Value (CSV) files, HTML, or XLS.

How do I force drop a database in SQL Server?

To remove a database from the current server without deleting the files from the file system, use sp_detach_db. USE master; ALTER DATABASE [databasename] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [databasename] ; Note, database backups will not be deleted as part of the process documented above.


1 Answers

I had the same problem. Accidentally deleted a database and could not get it removed from the list in SSMS.

In SSMS right click on database then "Delete". Ignore the error, press "Cancel" in dialog. Then right click on database again, choose "Policies"->"Delete Health States". Refresh the instance databases and the database should not be in the list.

like image 177
Nathan Avatar answered Sep 18 '22 03:09

Nathan