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

Troubleshooting Guide: SQL Server Error 6920 — Invalid XML Schema Collection Definition

Why This Error Happens

Error 6920 occurs when SQL Server 2025 attempts to register or alter an XML Schema Collection that contains a malformed xs:restriction definition. Specifically, an attribute is declared with use="prohibited" in a derived complex type, but that same attribute does not exist in the base type it is supposedly restricting. This is almost always caused by a hand-edited or improperly generated XSD file being imported into SQL Server, rather than a SQL Server configuration or permissions issue.

Step-by-Step Resolution Guide

Step 1: Locate and Isolate the Offending XSD File

  • Identify which CREATE XML SCHEMA COLLECTION or ALTER XML SCHEMA COLLECTION statement triggered the error by checking the SQL Server error log or the query that failed.
  • Export the raw XSD content to a local file for inspection:
  SELECT xml_schema_namespace('YourSchemaName', 'YourSchemaCollectionName');
  • Save the output to a .xsd file (e.g., C:\Temp\schema_review.xsd) using SQL Server Management Studio (SSMS).

Step 2: Validate the XSD Against W3C Schema Rules

  • Open the .xsd file in Visual Studio 2022/2025 or an XML editor with schema validation support.
  • Search for any <xs:attribute name="..." use="prohibited" /> entries inside <xs:restriction base="..."> blocks.
  • Confirm whether the attribute referenced actually exists in the parent/base complex type definition — if it does not exist there, use="prohibited" is invalid and must be removed or corrected.
  • Cross-check the base type hierarchy by tracing base="..." attributes up through all parent complexType definitions in the file.

Step 3: Correct the Schema and Re-import

  • Edit the XSD so the prohibited attribute either matches an attribute that genuinely exists in the base type, or remove the use="prohibited" declaration entirely if it is not needed.
  • Drop and recreate the schema collection with the corrected file:
  DROP XML SCHEMA COLLECTION YourSchemaName.YourSchemaCollectionName;
  GO
  CREATE XML SCHEMA COLLECTION YourSchemaName.YourSchemaCollectionName
  AS N'<paste corrected XSD content here>';
  GO
  • If the schema is deployed via a .dacpac or deployment script, update the source file in your project (e.g., SSDT/Visual Studio) to prevent the issue from recurring on future deployments.

Step 4: Check for Third-Party or Auto-Generated Schema Sources

  • If the XSD was auto-generated (e.g., exported from an external ERP system, SOAP WSDL, or XML tool), check for a newer version of that tool or export utility, as this is a common source of malformed restriction blocks.
  • Re-export or regenerate the schema from the source system rather than manually patching it, when possible.

Alternative or Verification Steps

  • Verify the fix by re-running the original CREATE/ALTER XML SCHEMA COLLECTION statement and confirming it completes without Error 6920, then test any stored procedures or columns typed against that schema collection with sample XML data.
  • As an alternative, use an independent XSD validator (such as xmllint --schema on Windows via WSL, or the .NET XmlSchemaSet class in a PowerShell script) to pre-validate the XSD file before importing it into SQL Server, catching structural errors earlier in the pipeline.