Delete a SharePoint 2010 service application database for a service application that was previously removed/deleted

In this post I will explain how to delete a SharePoint 2010 service application database for a service application that was previously removed/deleted.

When you remove your service application, you may see on on the page Central Administration > Management Databases Upgrade Status that the database is still visible even though it a) is not in use anymore and/or b) has been deleted from SSMS.

You may notice in the event log:

SQL Database ‘db_name’ on SQL Server instance ‘sql_instance’ not found. Additional error information from SQL

Server is included below.

Cannot open database “db_name” requested by the login. The login failed.
Login failed for user ‘login’.

To overcome this error and remove the old DB reference, fill your zombie DB name into the following PowerShell and execute from the SharePoint PowerShell interface:

get-spdatabase | where {$_.name -eq 'db_name'} | foreach {$_.Delete()};

This will remove the DB from SharePoint’s frame of reference and clear up any related error messages. Don’t forget – if the physical DB is still in SQL Server, you will need to go into SSMS and archive/delete it as ye may so desire.

delete database, service application

Leave a Reply

Your email address will not be published. Required fields are marked *