What to do if defragment of SharePoint database fails?

Hello @all,

today my colleague Steve Chen solve an interesting issue. He had the problem that the SQL script from my blog post “how to defrag sharepoint databases” fails with error message:

Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.

Additionally, information that is similar to the following may appear in the SQL Server 2005 Exception.log file:

<date> <time> spid 56 Exception 0xc0000005 EXCEPTION_ACCESS_VIOLATION reading address 00000020 at 0x0110B72B 2.

Normally the script runs successful and it was crazy to see this error message, BUT we are living in the support and everything has a cause and Steve found it:

It’s written in KB 910416Error message when you run certain queries or certain stored procedures in SQL Server 2005: “A severe error occurred on the current command”

In this case problem was that the SQL server was on patch level SQL SP2 with an previous Hotfix (Patch level smaller then SP2-Level) installed. So the pre-SP2 Hotfix overwrites SP2 files that cause the error.

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2005. Installing SP3 (KB 955706) for SQL 2005 and after that, the query to defrag databases runs successful.