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

Why This Error Happens

This error occurs when SQL Server 2025 encounters a nested INSERT...EXEC statement where the inner stored procedure or dynamic SQL attempts to return more than one column in its result set. The Query Optimizer strictly enforces a single-column restriction on nested inserts because the outer INSERT statement cannot resolve a multi-column mapping when a secondary execution context is already active. This typically surfaces after upgrading to SQL Server 2025 on Windows Server 2025, where stricter parsing of nested procedure calls now flags syntax that may have silently worked—or thrown a different warning—in older engine versions.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Nested INSERT Statement

  • Open SQL Server Management Studio (SSMS) and locate the exact stored procedure or batch referenced in the error output.
  • Check the sys.dm_exec_sql_text DMV or SQL Server Profiler/Extended Events trace to capture the exact query text that triggered Error 4155.
  • Confirm whether the procedure contains an INSERT INTO TableName EXEC AnotherProcedure pattern where AnotherProcedure itself contains a nested INSERT...EXEC.

Step 2: Refactor the Nested Logic to Avoid Double EXEC Nesting

  • Rewrite the inner procedure to populate a temporary table (#TempTable) or table variable instead of directly nesting another EXEC inside an INSERT.
  • Example fix:
  INSERT INTO #TempResults
  EXEC dbo.InnerProcedure;

  INSERT INTO FinalTable (Col1)
  SELECT Col1 FROM #TempResults;
  • Ensure the inner SELECT statement being inserted ultimately resolves to exactly one column per INSERT target when nesting cannot be avoided.

Step 3: Validate Compatibility Level and Query Hints

  • Run SELECT compatibility_level FROM sys.databases WHERE name = 'YourDBName'; to confirm the database compatibility level matches SQL Server 2025 standards (170).
  • If the procedure was migrated from an older SQL Server version, test with ALTER DATABASE YourDBName SET COMPATIBILITY_LEVEL = 160; temporarily to see if legacy parsing resolves the issue (useful for diagnosis, not a permanent fix).
  • Remove any unnecessary OUTPUT clauses or multi-column SELECT statements inside the nested EXEC call.

Step 4: Apply Latest Cumulative Update

  • On Windows Server 2025, open Windows Update or use SSMS > Help > Check for Updates to confirm you are on the latest Cumulative Update (CU) for SQL Server 2025, as early CUs had known parser regressions affecting nested INSERT...EXEC validation.
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (run as Administrator) after patching.

Alternative or Verification Steps

  • Re-run the original stored procedure or batch in SSMS and confirm Error 4155 no longer appears in the Messages tab; check the Windows Event Viewer (Application Log) to ensure no related SQL Server exceptions were logged.
  • If the error persists, bypass nested execution entirely by converting the inner procedure logic into a Table-Valued Function (TVF) and referencing it directly in the outer INSERT INTO ... SELECT statement.