For a long time, I had been using a single SPS 2003 content database. The database possibly became corrupt when one of our drives went down. To fix this, I was initially thinking of adding a new content database to the site and then deleting the old one. But this was certainly not a good idea as I would have lost all my valuable data this way. Moreover, if the content database was a default one, I could not be easily removed from the Manage Databases page in WSS Central Admin.

Another way out was to perform restoration from a recent clean backup. This would have required attaching and detaching the database in WSS Central Admin in order to allow ‘Site Detection’ to update the configuration database accordingly. Unfortunately, the backup wasn’t complete, so I had to rule out this option.

I was suspecting that the database had a number of orphaned items. I came across an excellent description of this problem on a Microsoft’s knowledge-base article. There is basically a new databaserepair command-line operation that can be used with the Stsadm.exe command-line tool to repair a content database. The only limitation was that these could detect and delete some specific orphaned items. Moreover, it could result in the creation of additional orphaned items. I decided to follow the process step by step.

First off, I tried to detect and delete the orphaned items as follows:

  • Navigated to ‘Start’, ‘Run’. Ran the ‘cmd’ command to open the command prompt.
  • Ran the following at the prompt:

‘cd /d %commonprogramfiles%\Microsoft Shared\Web Server Extensions\60\Bin’

‘stsadm -o databaserepair -url http://URLofWindowsSharePointServicesSite -databasename DatabaseName’

This showed a list of orphaned items present in the database.

  • Now, to delete these items, ran the following command:

‘stsadm -o databaserepair -url http://URLofWindowsSharePointServicesSite -databasename DatabaseName -deletecorruption’

  • Repeated the procedure several times until I got this message:

‘<OrphanedObjects Count=”0″ />’

Finally, I removed and reattached the content database on the virtual server. I tried to access the site again and found some items were still inaccessible. At this stage, I decided to go for commercial third-party SharePoint Server recovery tools. After reading a lot of reviews, I purchased Stellar Phoenix SharePoint Server recovery and it worked a treat. This tool easily repaired corruption in the SharePoint content database and safely restored all the inaccessible site content, such as documents, blogs, wikis, and other useful information.