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

Why This Error Happens

Error 2384 occurs when SQL Server validates XML data against a registered XML Schema Collection and finds that an element appears in an order, position, or frequency that violates the schema’s defined sequence or occurrence constraints (minOccurs/maxOccurs). This typically happens due to a mismatch between the application’s XML payload structure and the XSD schema stored in SQL Server, or because the schema collection itself was imported incorrectly or has become corrupted. It can also surface after an in-place upgrade to SQL Server 2025 where stricter XML validation parsing rules were introduced for schema collections.

Step-by-Step Resolution Guide

Step 1: Identify the Offending XML Schema Collection

  • Run SELECT name, schema_id FROM sys.xml_schema_collections; to list all registered collections on the database.
  • Cross-reference the collection name mentioned in the error message with the table/column using XML (CONTENT schema_name).
  • Use SELECT xml_schema_namespace(N'dbo', N'YourSchemaCollectionName'); to export the raw XSD for manual review.

Step 2: Validate the Incoming XML Payload Against the XSD

  • Open the exported XSD in Visual Studio 2022/2025 or an XML editor and check <xs:sequence>, <xs:choice>, and minOccurs/maxOccurs attributes for the failing element.
  • Compare the application-generated XML (from logs or a trace) against the schema order — look for duplicated elements, missing closing tags, or elements inserted out of sequence.
  • Correct the source application code or ETL job generating the XML so element order and counts match the schema exactly.

Step 3: Drop and Re-import a Clean Schema Collection

  • If the schema itself is suspected to be corrupted, back up the current definition, then run:
  DROP XML SCHEMA COLLECTION dbo.YourSchemaCollectionName;
  CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollectionName AS N'<xsd content>';
  • Ensure the XSD file has no encoding issues (UTF-8 without BOM is recommended) and was not truncated during copy/paste.

Step 4: Apply Latest Cumulative Update

  • Check Server Properties in SSMS or run SELECT @@VERSION; to confirm the exact build.
  • Install the latest SQL Server 2025 Cumulative Update from Microsoft, as XML parser fixes are frequently bundled in CU releases.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after patching.

Alternative or Verification Steps

  • Re-run the original INSERT/UPDATE statement or application transaction that triggered Error 2384; confirm it completes without validation errors and check sys.dm_exec_requests for a clean execution state.
  • As an alternative if schema correction isn’t feasible immediately, temporarily cast the column to untyped XML (without schema binding) to unblock operations, then re-apply schema validation once the payload generation logic is fixed.