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

Troubleshooting Guide: Error 2374 – “A node or set of nodes is required for %ls”

Why This Error Happens

Error 2374 occurs when SQL Server 2025 attempts to parse or execute an XML Schema Collection, XQuery expression, or XML DML statement that references a node path which does not resolve to any valid node in the target XML structure. This typically stems from a malformed XPath/XQuery expression, a mismatch between the expected XML schema and the actual XML instance data, or corruption in the XML index/schema collection metadata. It can also surface after an in-place upgrade to SQL Server 2025 if legacy XML schema collections were built against deprecated parsing behaviors no longer supported by the updated XQuery engine.

Step-by-Step Resolution Guide

Step 1: Validate the XQuery/XPath Expression Syntax

  • Open the stored procedure, function, or ad-hoc query that triggered Error 2374 in SQL Server Management Studio (SSMS) 21 or Azure Data Studio.
  • Check .nodes(), .query(), .value(), or .modify() calls for correct node path syntax — a missing / or incorrect namespace prefix is a common cause.
  • Run the query in isolation: SELECT XmlColumn.query('/Root/Node') FROM YourTable; to confirm the path resolves against sample data.

Step 2: Inspect and Repair the XML Schema Collection

  • Query existing schema collections: SELECT name, xml_collection_id FROM sys.xml_schema_collections;
  • Compare the registered schema against the actual XML documents being inserted using: SELECT SCHEMA_NAME(schema_id), name FROM sys.xml_schema_collections WHERE name = 'YourCollectionName';
  • If the schema is outdated or mismatched, drop and recreate it:
DROP XML SCHEMA COLLECTION YourCollectionName;
GO
CREATE XML SCHEMA COLLECTION YourCollectionName AS N'<your updated XSD content>';

Step 3: Rebuild XML Indexes on Affected Tables

  • Corrupted or stale primary/secondary XML indexes can cause node resolution failures during query execution.
  • Identify XML indexes on the affected table:
SELECT i.name, i.type_desc FROM sys.indexes i
WHERE i.object_id = OBJECT_ID('YourTableName') AND i.type_desc LIKE 'XML%';
  • Rebuild the index to clear any fragmentation or metadata drift:
ALTER INDEX PrimaryXmlIndexName ON YourTableName REBUILD;

Step 4: Apply the Latest SQL Server 2025 Cumulative Update

  • On Windows Server 2025 / Windows 11, open Settings > Windows Update or use SQL Server Setup to check for the latest Cumulative Update (CU), as early 2025 builds had known XQuery engine regressions affecting node-set evaluation.
  • Download and install the CU from the Microsoft Update Catalog, then restart the MSSQLSERVER service via services.msc or:
Restart-Service -Name MSSQLSERVER -Force

Alternative or Verification Steps

  • After applying fixes, re-run the original failing query/procedure and confirm Error 2374 no longer appears in the SQL Server Error Log (EXEC sp_readerrorlog;).
  • If the error persists, isolate the issue by testing the same XML document and schema in a clean tempdb table to rule out table-specific corruption versus a genuine schema/query defect.