Microsoft KB Archive/918744

= Description of a new command-line operation that you can use to repair content databases in Windows SharePoint Services 2.0 and SharePoint Portal Server 2003 =

Article ID: 918744

Article Last Modified on 10/24/2007

-

APPLIES TO


 * Microsoft Windows SharePoint Services 2.0
 * Microsoft Office SharePoint Portal Server 2003

-





SUMMARY
''This article discusses a hotfix that you can apply that enables you to repair content databases in Microsoft Windows SharePoint Services 2.0. The hotfix introduces a new command-line operation that you can use with the Stsadm.exe command-line tool. This article describes how to obtain the hotfix. It also describes how to use the Stsadm.exe command-line tool with the new databaserepair command-line operation to detect and to delete orphaned items in content databases in Windows SharePoint Services 2.0.''



INTRODUCTION
This article describes a new command-line operation in Windows SharePoint Services 2.0 that you can use to repair content databases. You can use the databaserepair command-line operation with the Stsadm.exe command-line tool to detect and to delete orphaned items in content databases.

In certain situations, a content database that is used by Windows SharePoint Services 2.0 may become corrupted. The corrupted database may contain orphaned items. For example, a document may not have a parent document library. Or, a list may not have a parent Windows SharePoint Services 2.0 Web site. Before the new command-line operation that is described in this article was introduced, Windows SharePoint Services 2.0 did not have a tool that you could use to repair and to maintain the integrity of a content database. The procedure that is described in this article is a supported method that you can use to repair content databases. Modifying a content database directly is not supported.

This update was first included in Windows SharePoint Services 2.0 Service Pack 3. For more information about the latest service pack for Windows SharePoint Services 2.0, click the following article number to view the article in the Microsoft Knowledge Base:

906795How to obtain the latest service pack for Windows SharePoint Services 2.0



How to obtain the hotfix
This issue is fixed in the Windows SharePoint Services post-Service Pack 2 Hotfix Package that is dated June 1, 2006. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

918743 Description of the Windows SharePoint Services post-Service Pack 2 hotfix package: June 1, 2006

Information about the hotfix
The hotfix adds a new databaserepair command-line operation that you can use with the Stsadm.exe command-line tool to repair a content database. You can use the Stsadm.exe command-line tool with the databaserepair operation to detect and to delete the following orphaned items in Windows SharePoint Services 2.0 content databases:
 * A Windows SharePoint Services 2.0 Web site that does not have a parent Windows SharePoint Services 2.0 Web site
 * A subweb that does not have a parent Windows SharePoint Services 2.0 Web site
 * A list that does not have a parent Windows SharePoint Services 2.0 Web site
 * A document that does not have a parent document library
 * A list item that does not have a parent list
 * A Web page that does not have a parent Windows SharePoint Services 2.0 Web site

The databaserepair operation uses the following parameters:
 * Required parameters: url, databasename
 * Optional parameter: deletecorruption

When you use the Stsadm.exe command-line tool with the databaserepair operation, the syntax is as follows.  To detect orphaned items, use the following command line:

stsadm -o databaserepair -url http:// -databasename  

 To delete orphaned items, use the following command line:

stsadm -o databaserepair -url http:// -databasename   -deletecorruption



Things to consider
Consider the following information before you perform the procedure that is described in this article to repair content databases in Windows SharePoint Services 2.0:
 * The Stsadm.exe command-line tool and the databaserepair operation can only detect certain types of orphaned items in a content database. The types of orphaned items that can be detected are listed earlier in the &quot;Information about the hotfix&quot; section.
 * When you use this procedure to delete orphaned items, additional orphaned items may be created. You may not be able to delete the additional orphaned items.
 * If you are running Microsoft Office SharePoint Portal Server 2003 and Windows SharePoint Services 2.0, this procedure may create orphaned items in the configuration database in SharePoint Portal Server 2003. After you perform this procedure, make sure that you run the Spsadm tool in SharePoint Portal Server 2003 to repair orphaned items in the configuration database.
 * The databaserepair operation removes orphaned items from content databases in Windows SharePoint Services 2.0. If orphaned items are present in the configuration database, you have to clean up the orphaned items in the configuration database. To do this, use the Window SharePoint Services Central Administration tool to remove the content databases from the virtual server. Then, reattach the content databases to the virtual server. When you remove a content database from a virtual server, the Windows SharePoint Services 2.0 Web sites that are in the content database are removed from the Sites table in the configuration database. If the Sites table in the configuration database lists Windows SharePoint Services 2.0 Web sites that are not present in the content database, the Windows SharePoint Services 2.0 Web sites are removed when the content database is removed from the virtual server. The Windows SharePoint Services 2.0 Web sites are not added back to the content database when you reattach the content database to the virtual server. When you remove and then reattach the content databases to virtual server, you remove orphaned items from the configuration database.

Step 1: Detect and delete orphaned items in Windows SharePoint Services 2.0 content databases
To use the Stsadm.exe command-line tool with the databaserepair operation to detect and to delete orphaned items, follow these steps:  Click Start, click Run, type cmd, and then click OK. Type the following line at the command prompt, and then press ENTER:

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

 Detect orphaned items in the database. To do this, type the following line at the command prompt, and then press ENTER:

stsadm -o databaserepair -url http:// -databasename

A list of containers that contain orphaned items that are detected by the Stsadm.exe command-line tool is displayed. The number that appears in the <OrphanedObjects Count=&quot; &quot;> line represents the number of orphaned containers. The following example is an example of a list that shows that 10 orphaned containers were detected by the tool:

<pre class="fixed_text"><OrphanedObjects Count=&quot;Number&quot;> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> <Orphan Type=&quot;SPList&quot; Id=&quot;{ID}&quot; SiteId=&quot;{ID}&quot; /> </OrphanedObjects>

</li> Delete orphaned items. To do this, type the following line at the command prompt, and then press ENTER:

stsadm -o databaserepair -url http:// -databasename   -deletecorruption

</li> Repeat steps 4 and 5 until the Stsadm.exe tool no longer detects any orphaned items. When orphaned items are no longer detected, the following data is displayed after you use the Stsadm.exe command-line tool:

<pre class="fixed_text"><OrphanedObjects Count=&quot;0&quot; />

</li></ol>

Step 2: Run the Spsadm.exe tool if you are running SharePoint Portal Server 2003
If you are running SharePoint Portal Server 2003, run the Spsadm.exe command-line tool with the repairorphans command-line operation to repair orphaned items that may be present in the configuration database. The repairorphans operation removes and then reattaches the _SITE content database. When you run the Spsadm.exe tool with the repairorphans operation, orphaned items that may exist for the _SITE content database are removed from the configuration database.

For more information about how to use the Spsadm.exe tool to clean up orphaned items in the configuration database, click the following article number to view the article in the Microsoft Knowledge Base:

918742 Description of a new command-line operation that is available for the Spsadm.exe command line tool that you can use to clean up orphaned items in the configuration database in SharePoint Portal Server 2003

Step 3: Remove and then reattach the content databases on the virtual server
When you remove a content database from a virtual server, the Windows SharePoint Services 2.0 Web sites that are stored in that content database are not available until you reattach the content database to the virtual server. To avoid down time for users, perform this step during off-peak hours on a day and at a time when the server is not heavily used.

To remove and then reattach the content database or content databases on the virtual server, follow these steps:
 * 1) Click Start, click Administrative Tools, and then click SharePoint Central Administration.
 * 2) Under Virtual Server Configuration on the Windows SharePoint Services 2.0 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:
 * 6) * The database server
 * 7) * The database name
 * 8) * The database capacity settings
 * 9) 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.
 * 10) Click OK.
 * 11) On the Manage Content Databases page, click Add a content database.
 * 12) On the Add a Content Database page, specify the database server, the database name, and the database capacity settings. Then, click OK.

Important Do not run the &quot;spsadm repairorphans&quot; command against a live portal farm that is not fully quiesced. When you run the Repairorphans tool on a portal farm, the following behavior is true:
 * The portal farm cannot be accessed by users.
 * The portal farm cannot be backed up by SQL or other backup software on either the SharePoint side or the SQL side of the farm.
 * The portal farm cannot have external OM code running during the complete operation of the &quot;repairorphans&quot; command.

You must configure the SharePoint Portal Server so that users cannot author against it or add content. You must also set the server to read only. For more information about how to do this, visit the following Web site to obtain the SharePoint Portal Server 2003 Administrator's Guide:

http://www.microsoft.com/downloads/details.aspx?familyid=47405143-F586-4941-92F5-048BF00CF332&displaylang=en&displaylang=en

<div class="references_section">