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

Why This Error Happens

Error 2378 occurs when SQL Server’s XML parser attempts to validate a document against an XML Schema Collection but encounters content that does not conform to the expected XML Schema Definition (XSD) structure. This typically happens when a malformed, truncated, or incorrectly namespaced XML document is passed into a column or variable that is typed with XML(SCHEMA COLLECTION ...). It can also surface when the registered schema collection itself has become corrupted or was registered with conflicting namespace definitions, causing the engine to reject even well-formed XML during insert or update operations.

Step-by-Step Resolution Guide

Step 1: Validate the Source XML Document

  • Open the XML payload being inserted and confirm it begins with a valid root element and, if applicable, a proper <?xml version="1.0"?> declaration.
  • Use a tool like SELECT CAST(@xmlVar AS XML) in a scratch query window to isolate whether the raw document is well-formed before schema validation is applied.
  • Check for truncation — large XML payloads exceeding buffer limits (especially via ODBC/OLE DB drivers on Windows Server 2025) are a common silent cause.

Step 2: Inspect and Repair the XML Schema Collection

  • Run the following query to review the registered schema collection definition:
  • SELECT name, xml_schema_namespace, schema_collection_id FROM sys.xml_schema_collections WHERE name = 'YourSchemaCollectionName';
  • If the collection appears incomplete or outdated, drop and re-add it using:
  • DROP XML SCHEMA COLLECTION YourSchemaCollectionName;
  • CREATE XML SCHEMA COLLECTION YourSchemaCollectionName AS N'<xsd:schema>...</xsd:schema>';
  • Ensure the targetNamespace attribute in the XSD exactly matches the namespace used in the incoming XML document.

Step 3: Check Application-Level Serialization Settings

  • On Windows 11/Windows Server 2025 clients, confirm that the application layer (e.g., .NET SqlXml or XmlDocument objects) is not re-encoding the payload with an unexpected encoding (UTF-16 vs UTF-8 mismatches are common).
  • Verify connection string parameters such as Packet Size are sufficiently large (e.g., Packet Size=32767) to avoid silent truncation of large XML blobs over the wire.

Step 4: Rebuild the Column Binding

  • If the error persists only on a specific table/column, script out the table, drop the XML(SCHEMA COLLECTION) typed column constraint, and recreate it after confirming the schema collection is valid:
  • ALTER TABLE YourTable ALTER COLUMN XmlCol XML(YourSchemaCollectionName);
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (run as Administrator) to clear any cached execution plans referencing the old schema.

Alternative or Verification Steps

  • Re-run the original INSERT/UPDATE statement after Step 2 — if it completes without Error 2378, the schema collection repair was the root cause.
  • As a fallback, temporarily cast the column to untyped XML (without schema binding) to confirm the document inserts successfully, isolating the issue to schema validation rather than XML well-formedness.