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

Troubleshooting Guide: SQL Server Error 454 – “The UNNEST Argument Must Be a Nested Table Column”

Why This Error Happens

Error 454 occurs when a Transact-SQL query attempts to use the UNNEST operator on an expression that is not a properly typed nested table column, such as a scalar value, a JSON string that hasn’t been cast to a native nested table type, or a column returned from an incompatible view. This typically happens after SQL Server 2025 schema migrations where legacy JSON/XML columns were not converted to the new native NESTED TABLE data type introduced in this release. It can also occur when application code (ORMs or ETL pipelines) passes a derived or aliased column into UNNEST() without first validating its underlying storage type.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column and Query

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio and locate the exact query from the error stack trace in the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • Run sp_help 'YourTableName' to inspect the column’s actual data type.
  • Confirm whether the column is defined as NESTED TABLE or is instead a plain VARCHAR, JSON, or XML type masquerading as nested data.

Step 2: Convert the Column to a Native Nested Table Type

  • If the column is JSON-based, alter the table to use the new type:
  ALTER TABLE dbo.YourTableName
  ALTER COLUMN NestedColumn NESTED TABLE OF dbo.YourRowType;
  • If the column is computed or aliased in a subquery, ensure the SELECT statement preserves the nested table type by avoiding implicit casts (e.g., CAST(... AS VARCHAR(MAX))), which strips nested metadata.
  • Rebuild any dependent views using sp_refreshsqlmodule 'YourViewName' after the alteration.

Step 3: Correct the UNNEST Syntax in the Query

  • Rewrite the query to reference the nested table column directly rather than a derived expression:
  SELECT t.ID, u.*
  FROM dbo.YourTableName t
  CROSS APPLY UNNEST(t.NestedColumn) AS u;
  • Avoid wrapping the column in functions like ISNULL() or COALESCE() before passing it to UNNEST(), as this breaks type inference.

Step 4: Update Statistics and Recompile

  • Run UPDATE STATISTICS dbo.YourTableName; to ensure the query optimizer has current metadata about the nested table column.
  • Force a recompile of cached execution plans with:
  EXEC sp_recompile 'YourTableName';
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER if plan caching persists.

Alternative or Verification Steps

  • Re-run the original query in SSMS and confirm Error 454 no longer appears; check sys.columns via SELECT name, system_type_id FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName') to verify the column now reports as a nested table type.
  • If the error persists, as a workaround, extract the nested data into a temporary staging table with the correct NESTED TABLE type using SELECT INTO, then apply UNNEST against the staging table instead of the original source.