Delete a Phantom Content Database

I’ve encountered this a few times, where a Content Database has gone missing, thus you need to delete a phantom Content Database. When encountering this scenario, typically when creating a Site Collection you’ll receive an error, and in the ULS you’ll find that SharePoint isn’t able to figure out what database to put it in. To determine if the cause is a non-existent database, use the SharePoint Management Shell and run:

$wa = Get-SPWebApplication http://spwebapp1

If the output looks similar to the following, you have a phantom database.

Id               : 9883a602-4218-4d73-aec7-9087d4761477
Name             : SharePoint_CDB1
WebApplication   : SPWebApplication Name=SharePoint
Server           : SPSQL
CurrentSiteCount : 6

Id               : 626c208d-0f3b-4d3f-b57e-5a72d1433e55
Name             : 
WebApplication   : SPWebApplication Name=SharePoint
Server           : SPSQL
CurrentSiteCount :
One might think that simply running Remove-SPContentDatabase -Identity or $db = Get-SPDatabase ?{$_.Id -eq “”};$db.Delete() would do the trick. Nope! The problem with those methods is they instatinate the database object… which doesn’t exist! Instead, we have to take an alternate approach using the SPWebApplication object via PowerShell.

That will cleanly remove the Content Database object from the Web Application.

Trevor Seward is a Microsoft Office Apps and Services MVP who specializes in SharePoint Server administration, hybrid scenarios, and SharePoint Online. He has been working with SharePoint for 16 years from SharePoint 2003 on up, managing environments with terabytes of content for 150,000+ user organizations. Trevor is an author of Deploying SharePoint 2016 and Deploying SharePoint 2019. You can find him on Twitter and in /r/sharepoint.