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

Troubleshooting Guide: SQL Server Error 2292 — XML Schema Collection Restriction Error

Why This Error Happens

This error occurs when a user-defined XML schema collection contains a type definition that attempts to restrict a base type with mixed content using simple content, which violates W3C XML Schema specification rules. This typically happens during CREATE XML SCHEMA COLLECTION or ALTER XML SCHEMA COLLECTION operations where the imported or inline XSD has inconsistent complexType derivation rules. The underlying cause is almost always a malformed or incorrectly authored XSD file rather than a SQL Server configuration issue.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Schema Collection

  • Run the following query to locate the schema collection causing the failure:
SELECT name, xml_schema_namespace, create_date 
FROM sys.xml_schema_collections 
WHERE schema_id = SCHEMA_ID('dbo');
  • Check SQL Server error logs at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the exact statement that triggered Error 2292.
  • Note the specific complexType or simpleContent element referenced in the error message.

Step 2: Validate and Correct the XSD Definition

  • Open the source .xsd file in Visual Studio 2022/2025 or an XML editor with schema validation enabled.
  • Locate the <xs:complexType> using <xs:simpleContent> that restricts a base type defined with <xs:complexContent mixed="true">.
  • Correct the derivation so that simple content types only restrict other simple content (or complex types with simple content) base types — not mixed-content complex types.
  • Example fix: change the base type reference in <xs:restriction base="..."> to a compatible simple-content type, or redefine the base type without mixed="true".

Step 3: Drop and Recreate the XML Schema Collection

  • Drop the broken schema collection:
DROP XML SCHEMA COLLECTION dbo.YourSchemaCollectionName;
  • Recreate it using the corrected XSD:
CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollectionName AS N'<corrected XSD content here>';
  • Confirm no dependent XML columns or typed XML variables are broken by this operation beforehand using sys.columns and sys.xml_schema_collections joins.

Step 4: Test in a Non-Production Environment First

  • Deploy the corrected schema to a Windows Server 2025 test instance of SQL Server 2025.
  • Run the full application workflow that generates or consumes the XML data to confirm no downstream serialization errors occur.

Alternative or Verification Steps

  • Verify the fix by re-running the original CREATE/ALTER XML SCHEMA COLLECTION statement — it should complete without Error 2292, and you can confirm via SELECT * FROM sys.xml_schema_collections that the new collection is registered.
  • If you cannot modify the source XSD (e.g., third-party schema), use an XML Schema validation tool (such as xmllint --schema or the .NET XmlSchemaSet class) outside of SQL Server first to pinpoint and simplify the mixed/simple content conflict before re-importing.