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

Troubleshooting Guide: SQL Server Error 2319 – “This type may not have a ‘%ls’ facet”

Why This Error Happens

Error 2319 occurs when SQL Server’s XML Schema Collection validation engine encounters a facet (such as maxLength, pattern, or totalDigits) applied to a base type that does not support it according to the W3C XML Schema specification. This typically happens when a custom or imported XSD schema is malformed, was hand-edited incorrectly, or was generated by a third-party tool that does not strictly enforce W3C type-facet compatibility rules. It can also surface after an in-place upgrade to SQL Server 2025, where stricter XML schema validation parsing exposes previously tolerated inconsistencies in existing XML Schema Collections.

Step-by-Step Resolution Guide

Step 1: Identify the Offending XML Schema Collection

  • Run the following query to locate collections and inspect their definitions:
  • SELECT name, xml_schema_namespace, XML_SCHEMA_NAMESPACE('schema_name','collection_name') FROM sys.xml_schema_collections;
  • Note the exact Location path and facet name (%ls) reported in the error message — this points to the specific <xs:restriction> block causing the conflict.

Step 2: Validate the Schema Against W3C XSD Rules

  • Export the schema collection definition to a .xsd file using SSMS (Script Table As > XML Schema Collection).
  • Open the file in Visual Studio 2022+ or an XML validator (e.g., xmllint --noout --schema base.xsd target.xsd) to confirm facet/type compatibility.
  • Common invalid combinations include applying maxLength to xs:decimal or pattern to xs:boolean — remove or correct these facets.

Step 3: Drop and Recreate the Corrected Schema Collection

  • Back up the current collection definition before making changes:
  • SELECT CAST(XML_SCHEMA_NAMESPACE('schema_name','collection_name') AS NVARCHAR(MAX));
  • Drop the invalid collection: DROP XML SCHEMA COLLECTION schema_name.collection_name;
  • Recreate it with the corrected XSD: CREATE XML SCHEMA COLLECTION schema_name.collection_name AS '<corrected XSD content>';

Step 4: Apply Latest Cumulative Update

  • Confirm you are running the latest Cumulative Update (CU) for SQL Server 2025, as early XML parser builds may misreport facet validation on otherwise valid schemas.
  • Check current build: SELECT @@VERSION;
  • Download and apply the latest CU from the Microsoft Update Catalog if your build is outdated.

Alternative or Verification Steps

  • After recreating the schema collection, re-run any stored procedures or XML column constraints that referenced it to confirm Error 2319 no longer appears.
  • If the error persists, temporarily isolate the schema by testing it in a clean tempdb database using CREATE XML SCHEMA COLLECTION — this confirms whether the issue is schema-specific or related to database-level corruption requiring a DBCC CHECKDB run.