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

Why This Error Happens

Error 2264 occurs when a Transact-SQL statement attempts to use the XML DML delete method to remove a document node (the root node) from an xml-typed column or variable instead of a specific child element or attribute node. SQL Server’s XQuery/XML DML engine enforces that the document node itself must always exist as a container, so any .modify('delete /') style operation targeting the root is rejected. This typically stems from an incorrectly scoped XPath expression in application code or a stored procedure that was generated dynamically without validating the target node path.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Enable SQL Server Profiler or Extended Events on the instance to capture the exact T-SQL batch that throws Error 2264.
  • Look specifically for .modify('delete ...') calls against xml typed columns in your stored procedures or ORM-generated SQL (common with Entity Framework or Dapper XML mapping layers).

Step 2: Correct the XPath Target in the Delete Statement

  • Open the stored procedure or application code in SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance.
  • Replace any root-level path (e.g., delete /) with a path that targets a specific child node, such as:
  UPDATE dbo.YourTable
  SET XmlColumn.modify('delete /Root/ChildNode[1]')
  WHERE Id = @Id;
  • Ensure the XPath expression always resolves to an element, attribute, or comment node — never the document node itself.

Step 3: Validate the XML Schema Collection (If Applicable)

  • If the column uses a typed XML schema collection, run the following to confirm the schema still matches expected node hierarchy:
  SELECT xml_schema_namespace('dbo','YourSchemaCollection');
  • On Windows Server 2025, verify no recent Windows Update or SQL Server Cumulative Update altered XML parser behavior by checking Control Panel > Programs > View Installed Updates against your SQL Server build number.

Step 4: Deploy and Test the Fix

  • Save and redeploy the corrected stored procedure using sqlcmd or SSMS deployment.
  • Re-run the original failing transaction in a test/staging database first to confirm Error 2264 no longer triggers.

Alternative or Verification Steps

  • Run SELECT @@VERSION; in SSMS to confirm you’re on the latest SQL Server 2025 Cumulative Update, as early builds had stricter XML DML validation that may require query adjustments.
  • As a quick verification, wrap the .modify() call in a TRY...CATCH block and log the ERROR_MESSAGE() output to confirm the exception no longer surfaces during batch execution.