Delete Orphaned Sites in SharePoint

So I ran into an issue the other day with deleting a SharePoint site. I needed to delete a site and re-create it because of our migration. To do this I went to Site Setting on the specific site and deleted it from the web browser. I have done this before with this site because I needed to practice the migration, no issues before. This time although the server was moving slow, and because of this it just continued to try and delete the site with no confirmation page that it was successful. The page was gone so I thought all was well. This was until I saw errors coming from the server logs relating to the page I had deleted! I looked in the Central Administration page to check the site list, the site was still there! I clicked to delete the site from the Central Administration page but it would not work, no option to delete. I then tried to delete the site with STSADM.EXE but I got this error with both stsadm.exe -o deletesite and stsadm.exe -o deleteweb: The system cannot find the path specified. (Exception from HRESULT: 0×80070003). I searched this error on the internet and found a solution which did finally work.

Go here for the Microsoft solution: http://support.microsoft.com/default.aspx?scid=kb;EN-US;918744

I did the following.

Step 1: I opened a Command Prompt and went to this directory: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

I typed in the following to list the orphaned sites:
stsadm -o databaserepair -url http://URLofWindowsSharePointServicesSite -databasename DatabaseName

I then typed the following to delete the orphaned sites:
stsadm -o databaserepair -url http://URLofWindowsSharePointServicesSite -databasename DatabaseName -deletecorruption

This didn’t harm anything but didn’t seem to do anything either. Since I did preform this step I cannot say it didn’t help and I can’t say it did, so i would do it just in case.

Step 2: This was the final step that did fix the issue. Remove and then reattach the content databases on the virtual server. I am quoting this from Microsoft:

1. Click Start, click Administrative Tools, and then click SharePoint Central Administration.

2. Under Virtual Server Configuration on the Windows SharePoint Services Central Administration page, click Configure virtual server settings.

3. Click the virtual server that you want to configure, and then click Manage content databases under Virtual Server Management on the Virtual Server Settings page.

4. On the Manage Content Databases page, click the content database that you want to remove.

5. On the Manage Content Database Settings page, note the following settings:
• The database server
• The database name
• The database capacity settings

6. Click to select the Remove content database check box, and then click OK. When you are prompted to confirm that you want to remove the content database, click OK.

7. Click OK.

8. On the Manage Content Databases page, click Add a content database.

9. On the Add a Content Database page, specify the database server, the database name, and the database capacity settings. Then, click OK.

I hope this helps. It worked for me. The sites were gone completely and I was able to create the new site with the old name.

- Kevin C -

7 comments so far

  1. Soeren on

    Hi Kevin,

    I have the same problem but Microsoft Support will not give me the fix.

    “Thanks for your email, I tried calling you to have a word with you, but unfortunately you were not available. It seems that the Hotfix you looking for is not available as of now”……

    Could you please send me a copy of the fix?

    Regards,

    Søren

  2. [...] web application. The detach and attach process can be done in the central adminsitration. Read this blog post which I think mentions how to detach/re-attach using the SPS 2003 Centram Admin. In SPS 2007, just [...]

  3. sat on

    Thanks a bunch. This helped me from pulling out all the remaining hair on my head.
    Worked like a charm. In fact I think once in a while we should do this to clean up the mess inside after the repair command.
    Thanks

  4. Brad Cote on

    This worked great – I was getting orphan errors when trying to run a content deployment from one Web app to another. The repairdatabase command did not work – I kept getting an error that it could not find the server. Removing and then attaching did the trick. Now the content deployment job runs fine.

  5. [...] after my colleague found this article explaining how to delete orphaned sites from WSS, we were able to solve the whole problem using [...]

  6. Soenke on

    And it still helps people! :-)

    Thanks a lot, worked great for me and prevented my hair tunring grey all over…

  7. Halfdann on

    This worked for me, when I ran the database repair option it showed 0 corrupt items, however detatching and re-attaching the database cleared it up.


Leave a reply