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

Troubleshooting Guide: SQL Server Error 6993 – Attribute Value Constraint Mismatch

Why This Error Happens

Error 6993 occurs when SQL Server 2025 parses an XML Schema Collection (XSD) where an attribute reference redefines a fixed or default value constraint that conflicts with the value declared in the original attribute definition. This typically happens after importing a third-party or legacy XML schema into SQL Server without validating it against W3C XML Schema consistency rules. It can also surface after an in-place upgrade from older SQL Server versions, where legacy XML Schema Collections that were previously tolerated are now strictly validated by the updated XML parser engine in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Offending XML Schema Collection

  • Run the following query to locate recently modified or problematic schema collections:
  • SELECT name, xml_schema_namespace, create_date, modify_date FROM sys.xml_schema_collections ORDER BY modify_date DESC;
  • Cross-reference the timestamp with the SQL Server error log entry for Error 6993 to isolate the exact collection and attribute name reported in the %s placeholder.

Step 2: Export and Inspect the Raw XSD Definition

  • Extract the schema content using:
  • SELECT xml_schema_namespace(N'dbo', N'YourSchemaCollectionName');
  • Open the exported XSD in a text editor or Visual Studio XML Editor and search for the flagged attribute.
  • Check both the <xs:attribute> declaration and any <xs:attribute ref="..."> usage to compare their fixed or default values — they must match exactly in value and type.

Step 3: Correct the Value Constraint Mismatch

  • Edit the XSD source file so the fixed/default value on the attribute reference matches the base declaration, or remove the redundant constraint from the reference entirely.
  • Save the corrected schema as a new .xsd file (e.g., C:\SQLSchemas\corrected_schema.xsd).
  • Drop the broken collection and recreate it:
  • DROP XML SCHEMA COLLECTION dbo.YourSchemaCollectionName;
  • CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollectionName AS N'<paste corrected XSD content here>';

Step 4: Clear Cached Query Plans Referencing the Schema

  • Since the old (invalid) schema may be cached in execution plans, flush the relevant plan cache:
  • DBCC FREEPROCCACHE;
  • Restart the SQL Server 2025 service via Services.msc or net stop MSSQLSERVER && net start MSSQLSERVER on Windows Server 2025 to ensure the XML parser reloads cleanly.

Alternative or Verification Steps

  • Validate the fix by re-running any stored procedures or application calls that insert/validate XML typed columns against this schema — no Error 6993 should appear in ERRORLOG (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • If the schema is from a third-party vendor and cannot be edited, use an external validator like xmllint --schema or Visual Studio’s “Validate XML” feature to confirm W3C compliance before re-importing it into SQL Server.