Orphaned Entry in Config Database RRS feed

  • Question

  • I have an orphaned entry of a SharePoint content database pointer in the Configuration database.  When I try to add a content database with the same name, I get the following error message:


    Through Central Administration, mount an existing content database:



    The attach operation cannot continue because another object 
    in this farm already contains the same ID. Each object in a
    farm must have a unique ID. In order to proceed with the attach
    operation you must assign a new ID to this database. To attach
    this database with a new ID, use the Mount-SPContentDatabase
    command with the -AssignNewDatabaseId parameter. Note that if
    this new database and an existing database contain the same
    site collections, attaching this database will likely result
    in orphaned site collections due to conflicts between the
    two databases. Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: GUIDHERE

    Date and Time: 12/20/2010 2:24:36 PM



    From powershell, mount an existing content database to the farm.  Mount-SPContentDatabase "MyContentDatabase" -WebApplication http://mywebapplication -ClearChangeLog -AssignNewDatabaseId



    Mount-SPContentDatabase : A SharePoint database named MyContentDatabase already exists. Y
    ou must supply another name for the new database. At line:1 char:24 + Mount-SPContentDatabase <<<< "MyContentDatabase" -WebApplication http://mywebapplication
    -ClearChangeLog -AssignNewDatabaseId + CategoryInfo : InvalidData: (Microsoft.Share...ContentDatabase: SPCmdletMountContentDatabase) [Mount-SPContentDatabase], SPDuplicateObject Exception + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMountContentDatabase


    Tried dismounting the database through powershell.  Dismount-SPContentDatabase "MyContentDatabase"


    Dismount-SPContentDatabase : The content database could not be found.
    At line:1 char:27
    + Dismount-SPContentDatabase <<<< "MyContentDatabase"
     + CategoryInfo  : InvalidData: (Microsoft.Share...ContentDatabase:
     SPCmdletDismountContentDatabase) [Dismount-SPContentDatabase], SPException
     + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletDismount



    Tried clearing orphans through stsadm command. stsadm -o databaserepair -url "http://mywebapplication" -databasename "MyContentDatabase"


    Value does not fall within the expected range.



    Verified there is an orphaned entry in the config database.  Running this SQL query yields a returned record:


    	Objects WITH
    (nolock) WHERE


    How do I resolve this issue in a MS-supported manner?

    Frederick Lin, http://fredericklin.com
    • Edited by Frederick Lin Monday, December 20, 2010 10:33 PM formatting
    Monday, December 20, 2010 10:32 PM


  • Try this to delete the orphaned database:

    $orphanedDB = Get-SPDatabase | where{$_.Name -eq "MyContentDatabase"}
    Wednesday, December 29, 2010 3:45 AM

All replies

  • From Technet: 
    You cannot attach the same content database more than once to a farm, even on different Web applications. Each site collection in a content database has a GUID that is associated with it, which is registered in the configuration database. Therefore, you cannot add the same site collection twice to the farm, even in separate Web applications. Although you can successfully attach the database in this situation, you will be unable to start the site collection.

    If you need a duplicate copy of a site collection in the same farm, first attach the database that contains the site collection to a separate farm, and then use the Stsadm backup and restore operations to copy the site collection over to the other farm. The Stsadm backup and restore process creates a new GUID for the site collection.

    You have 2 options here. Either 1) find a supported way of removing the orphaned entry in the config database and then attach your database or 2) follow the suggested approach from Technet of attaching to a separate farm. 

    Wednesday, December 29, 2010 12:00 AM
  • Try this to delete the orphaned database:

    $orphanedDB = Get-SPDatabase | where{$_.Name -eq "MyContentDatabase"}
    Wednesday, December 29, 2010 3:45 AM
  • JohnXO, it worked! Thank you!
    Frederick Lin, http://fredericklin.com
    Wednesday, December 29, 2010 6:42 PM
  • Superb!!! Worked like a charm...

    Thanks a lot John.


    Anupam Shrivastava
    Monday, January 24, 2011 5:56 AM
  • very nice
    Friday, June 8, 2012 7:29 PM
  • This helped me greatly! Thanks a lot JohnXO.
    Thursday, February 21, 2013 2:57 PM
  • Hi,

    I had faced same issue in our farm. 

    $OrphanDB = Get-SPDatabase | Where {$_.Name -eq "Content_Database_4"}


    Id               : feaf884522-3567-4dfe-87d2-753ae498343
    Name             : Content_Database_4
    WebApplication   :
    Server           : ProdContent1
    CurrentSiteCount : 125


    Then used mount-spcontentdatabase

    It worked fine.


    Wednesday, August 13, 2014 7:33 AM
  • Running the $OrphanDB.Delete(), did that actually delete the db? or just the entry in the configdb?
    Thursday, September 4, 2014 3:47 PM
  • Running OrphanedDB.Delete() will delete entry from config file or from SQL?
    Friday, July 13, 2018 5:55 AM