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

Why This Error Happens

Error 2263 occurs when SQL Server attempts to validate or query a typed XML instance against an XML Schema Collection, but the specified element name and namespace combination cannot be located within that schema type. This typically results from a mismatch between the XQuery expression used in your T-SQL statement and the actual schema definition, often caused by an incorrect namespace prefix, a typo in the element name, or a schema collection that was altered/updated without corresponding application code changes. In some cases, this also surfaces after an in-place upgrade to SQL Server 2025 where cached execution plans reference outdated schema metadata.

Step-by-Step Resolution Guide

Step 1: Identify the Failing Query and Schema Collection

  • Capture the exact T-SQL statement from SQL Server Management Studio (SSMS) or the application log that triggered Error 2263.
  • Run the following to list schema collections in the database:
SELECT name, xml_schema_namespace FROM sys.xml_schema_collections;
  • Note the namespace and element names expected in the error message (formatted as “namespace:element”).

Step 2: Validate the XML Schema Collection Definition

  • Query the schema collection content to confirm the element actually exists:
SELECT xml_schema_namespace('dbo', 'YourSchemaCollectionName');
  • Open the result in a new query window and search for the exact element/namespace referenced in your XQuery .value(), .query(), or .exist() method call.
  • Check for case sensitivity mismatches, since XML schema validation in SQL Server 2025 is case-sensitive by default.

Step 3: Correct the Namespace Prefix in Your T-SQL Code

  • Edit your query to use WITH XMLNAMESPACES and ensure the prefix matches the schema collection exactly, for example:
WITH XMLNAMESPACES ('http://schemas.yourcompany.com/orders' AS ord)
SELECT XmlColumn.value('(/ord:Order/ord:ID)[1]', 'int')
FROM YourTable;
  • Save and re-run the corrected query against a test environment first.

Step 4: Refresh or Re-register the XML Schema Collection

  • If the schema itself was updated upstream, drop and recreate the schema collection to ensure SQL Server’s internal metadata is current:
DROP XML SCHEMA COLLECTION dbo.YourSchemaCollectionName;
GO
CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollectionName AS N'<schema XML here>';
  • Restart the SQL Server service via services.msc on Windows Server 2025 if cached plans continue to reference the old schema after the update.

Step 5: Clear Cached Execution Plans

  • Flush the procedure cache to eliminate stale XQuery compilation artifacts:
DBCC FREEPROCCACHE;
  • Re-execute the original failing query to confirm the plan recompiles against the updated schema.

Alternative or Verification Steps

  • Verify the fix by executing the original application transaction or stored procedure in a staging environment and confirming no Error 2263 appears in the SQL Server Error Log (Event Viewer > Applications and Services Logs > MSSQLSERVER).
  • If the error persists, use sp_helptext on any stored procedures referencing the schema collection to locate hard-coded namespace strings that may need manual correction across multiple objects.