I have a customer with a public-facing SharePoint website that is fed by a staging site. This week we found an issue where some of the content on one of the production pages would not render; however, it was rendering fine in the staging environment. We tried many things to fix the issue; however, nothing worked. Ultimately, we decided to drop the site collection, re-create the site collection, and then re-publish the content.
Everything was going great until I ran the deployment job and received the following error:
"Unable to import the folder xxxx. There is already an object with the Id xxxx
in the database from another site collection."
I thought maybe I hadn't selected the "select template later" option when re-creating the site collection so I dropped the site collection, re-created it, and tried publishing again; however, I received the same error. After doing a few searches I found a post here that had the answer: my database had some orphaned objects that needed to be cleaned up. Per Melick's blog post, I ran the following in SharePoint Powershell:
stsadm -o databaserepair -url <url name> -databasename <database name>
Running the above will show if there are any orphaned objects. In my case, there were many, so I ran the following command:
stsadm -o databaserepair -url <url name> -databasename <database name> -deletecorruption
After that everything was cleaned up and I was able to publish the content to the site collection without having to drop the application as was suggested in several blog posts.