"Msg 6602" error when you execute the sp_xml_preparedocument stored procedure in SQL Server 2008, SQL Server 2008 R2, or SQL Server 2012

Article translations Article translations
Article ID: 2782589 - View products that this article applies to.
Expand all | Collapse all


When you try to execute a sp_xml_preparedocument stored procedure in Microsoft SQL Server 2008, SQL Server 2008 R2, or Microsoft SQL Server 2012 in which the content of the xmltext parameter is a complex XML document, you receive an error message that resembles the following:

The XML parse error 0x80004005 occurred on line number 1, near the XML text "<XML document sample>"
Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1
The error description is 'Unspecified error'.


This issue occurs because of a design limitation of the MSXML parser (Msxmlsql.dll) that SQL Server uses.

The issue is not strictly related to the size of the XML document but to its complex structure. A combination of the XML element's structure depth, the number and size of attributes, and the number of entities within attributes can cause this issue. However, the level of complexity that is required to reach this limit is usually found in XML documents that are several megabytes.


To work around this issue, try to reduce the complexity of the XML document.

Note Beware of very large single string attributes that contain many XML &#xA; entities.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.


Article ID: 2782589 - Last Review: January 9, 2013 - Revision: 2.1
Applies to
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Service Pack 2
  • Microsoft SQL Server 2012 Developer
  • Microsoft SQL Server 2012 Enterprise
  • Microsoft SQL Server 2012 Service Pack 1
  • Microsoft SQL Server 2012 Standard
kbsurveynew kbtshoot kbexpertiseadvanced KB2782589

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com