Wednesday, July 30, 2014

Tips to Repair Corrupt SharePoint Database


Application started reporting an IO error in the SharePoint database, and end users started getting below error message:

Cannot complete this action. Please try again

Solution: If you have encounter above error message in the SharePoint database then try following methods to fix it.

Try command line tool - Databaserepair: Stsadm operation
It detects & deletes orphaned items from corrupt SharePoint content database. SharePoint content database can be corrupt or damaged due to any uncertain reasons like hardware failure, power failure, virus attack etc. and corrupted SharePoint database may contain orphaned items. An example of orphaned item is a document may not have parent document.

Here is the syntax of Databaserepair - Stsadm operation:

Run follow syntax to detect an orpahned site
stsadm -o databaserepair -url <url name> -databasename <database name>
Example: stsadm -o databaserepair -url <http://myfirstsite.com> -databasename <my first site>
Run follow syntax to detect an orpahned site
stsadm -o databaserepair -url <url name> -databasename <database name>[-deletecorruption]
Example: stsadm -o databaserepair -url <http://myfirstsite.com> -databasename <my first site> -deletecorruption


Force PowerShell to Repair Content Database
To do this, you have to load the SharePoint management shell and run following equivalent powershell command:
$db = Get-SPDatabase "Content_DB_Name";
$db.Repair($false);
$db.Update();

If both the above methods fail to repair corrupt SharePoint database then check the consistency of your database by disconnecting it from the SharePoint. You can detach a content database from SharePoint using “Deletecontentdb: Stsadm” operation. It detaches a content database when database name, server and web application are specified.
Here is the syntax of Deletecontentdb - Stsadm operation:

stsadm -o deletecontentdb -url <url name> -databasename <database name> [-databaseserver] <database server name>

Now, follow below steps to check the consistency of database after detaching it:
  • Login into SQL server
  • Go to the SQL server management studio
  • Run following command:
    • USE WSS_CONTENT GO
    • ALTER DATABASE WSS_CONTENT SET SINGLE_USER GO
    • DBCC CHECKDB ('WSS_CONTENT') WITH NO_INFOMSGS
  • You will get error message details & recommendation to fix the error message.
  • Re-run DBCC CHECKDB with suggested repair clause (repair_fast, repair_rebuild, & repair_allow_data_loss).
Note: Some amount of data will be lost after performing repair_allow_data_loss, and the data loss is directly proportional to the level of corruption.
 
It is a 3rd party recovery software that easily detects & repairs corrupt SharePoint database. Software does not alter the content of database because it is read only in nature.


No comments:

Post a Comment