How to fix Error 2299 on Windows Server 2025 / Windows 11

Microsoft SQL Server 2025 Troubleshooting Guide: Error 2299

Why This Error Happens

Error 2299 occurs when SQL Server attempts to parse an XML document against its associated XSD (XML Schema Definition) but finds that a mandatory attribute defined in the schema is absent from the instance document. This typically results from a corrupted or truncated XML payload, a mismatch between an application’s XML output and an updated schema collection, or manual edits to XML configuration files (such as Policy-Based Management policies or SSIS package XML) that stripped out required metadata. It can also surface after an in-place upgrade to SQL Server 2025 if legacy XML schema collections were not validated against the new, stricter XSD parser.

Step-by-Step Resolution Guide

Step 1: Identify the Offending XML Source and Schema Collection

  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact timestamp and query context that triggered Error 2299.
  • Run the following query to locate custom XML Schema Collections tied to the affected database:
  SELECT name, xml_schema_namespace FROM sys.xml_schema_collections;
  • Note the specific element and attribute name mentioned in the error message (e.g., "%ls"), as this tells you exactly which XSD definition is being violated.

Step 2: Validate and Repair the XML Instance Document

  • Extract the raw XML causing the failure (common sources include SSIS .dtsx package files, Policy-Based Management XML exports, or application-submitted XML data columns).
  • Open the file in a validating XML editor (e.g., Visual Studio 2022/2025 or VS Code with an XML extension) and run “Validate XML” against the linked XSD.
  • Manually re-insert the missing required attribute, ensuring correct casing and namespace prefix (XSD attribute names are case-sensitive).
  • If the XML originates from an SSIS package, re-deploy the package from the original project source in SSDT rather than editing the .dtsx file by hand.

Step 3: Verify the XSD Schema Collection Integrity

  • If the schema itself was altered during a migration, re-import the original, unmodified XSD using:
  CREATE XML SCHEMA COLLECTION dbo.MySchemaCollection AS '<schema content>';
  • If upgrading from an older version (SQL Server 2019/2022), confirm compatibility level using:
  SELECT compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • Ensure the service account running the SQL Server instance (via services.msc on Windows Server 2025) has Read/Write access to any network share or folder where the XML/XSD source files are stored.

Step 4: Restart the SQL Server Service and Clear Cached Plans

  • Open SQL Server Configuration Manager, restart the SQL Server (MSSQLSERVER) service to clear any cached invalid XML schema metadata.
  • Alternatively, run DBCC FREEPROCCACHE; in SSMS to force re-compilation of stored procedures that reference the XML schema collection.

Alternative or Verification Steps

  • Re-run the original query or application process that threw Error 2299; if successful, query sys.dm_exec_query_stats to confirm no residual errors are logged against the affected object.
  • If the error persists, bypass strict schema validation temporarily by casting the column as untyped XML instead of a schema-bound type, then isolate the problematic attribute by comparing it against a known-good XML sample using diff or a text comparison tool.