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

Why This Error Happens

This error occurs because the intermediate column produced by the nodes() method (typically referenced as a virtual table column, e.g., T.c.query('...')) is being referenced directly in a SELECT list or WHERE clause without invoking a proper XML data type method. SQL Server’s nodes() function generates a rowset of typed XML fragments, and these fragments are not queryable as scalar values—they require one of .query(), .value(), .exist(), or .nodes() to extract or evaluate their content. This typically stems from a query written incorrectly during T-SQL development, migration from an older SQL Server version, or an ORM-generated query that improperly handles shredded XML columns.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Locate the query referenced in the error message using SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.
  • Check the Activity Monitor or query the sys.dm_exec_query_stats DMV to capture the exact query text if it was executed via an application layer.
  • Look specifically for a CROSS APPLY nodes() clause followed by a direct reference to the shredded column (commonly aliased as c or x).

Step 2: Rewrite the Query to Use a Valid XML Method

  • Modify the SELECT statement so that the column derived from nodes() is wrapped in .value(), .query(), .exist(), or another nested .nodes() call.
  • Example fix: Change SELECT T.c FROM XmlTable CROSS APPLY XmlColumn.nodes('/root/element') AS T(c) to SELECT T.c.value('.', 'NVARCHAR(100)') FROM XmlTable CROSS APPLY XmlColumn.nodes('/root/element') AS T(c).
  • If you need the raw XML fragment, use .query('.') instead of referencing T.c directly.

Step 3: Validate XML Schema Collections (If Applicable)

  • If the XML column is bound to an XML SCHEMA COLLECTION, verify the schema in SSMS Object Explorer under Databases > [YourDB] > Programmability > Types > XML Schema Collections.
  • Ensure the schema hasn’t changed in a way that invalidates the typed nodes being referenced, which can compound the error when combined with incorrect method usage.

Step 4: Update Application or ORM-Generated Queries

  • If the query originates from an ORM (e.g., Entity Framework, Dapper) or a reporting tool, locate the raw SQL template in your application code (commonly under /Data/Repositories/ or .sql files bundled with the app).
  • Patch the generated query manually or override the ORM’s raw SQL execution to include the required .value() or .query() method calls.

Step 5: Test in Isolation

  • Run the corrected query directly in SSMS against a test database to confirm Error 493 no longer appears.
  • Check the Messages tab in SSMS for confirmation of successful execution with the expected row count returned.

Alternative or Verification Steps

  • Verify the fix by executing the corrected query with SET STATISTICS XML ON to confirm the XML data is being parsed and returned as scalar or fragment values, not raw node references.
  • If the issue persists after rewriting the query, check for nested CROSS APPLY nodes() calls further upstream in views or stored procedures that may be feeding malformed XML column references into the outer query.