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

SQL Server 2025 Troubleshooting Guide: Error 156

Why This Error Happens

Error 156 (“Incorrect syntax near the keyword ‘%.*ls'”) occurs when the SQL Server parser encounters a reserved keyword used improperly within a T-SQL statement, typically as an unquoted object name, column alias, or identifier. This is common when reserved words like ORDER, LEVEL, USER, or new SQL Server 2025-specific reserved keywords are used without proper delimiters. It can also surface after an upgrade or compatibility level change, where words that were previously safe to use as identifiers become reserved in the newer engine version.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Keyword and Query Context

  • Locate the exact line number and statement referenced in the error message, using SQL Server Management Studio (SSMS) or Azure Data Studio’s error pane.
  • Cross-reference the flagged word against the official “Reserved Keywords” list in Microsoft Docs for SQL Server 2025.
  • Check if the query was migrated from an older compatibility level (e.g., a linked server or legacy application script).

Step 2: Wrap the Identifier in Delimiters

  • Enclose the offending object name, column, or alias in square brackets, e.g., [Order] instead of Order.
  • Alternatively, use double quotes if QUOTED_IDENTIFIER is set to ON for the session: SET QUOTED_IDENTIFIER ON;
  • Re-run the query in SSMS to confirm the parser accepts the syntax.

Step 3: Review Database Compatibility Level

  • Open SSMS, right-click the database, and navigate to Properties > Options.
  • Check the Compatibility Level field; if set to a newer level (e.g., 170 for SQL Server 2025), verify that legacy scripts do not rely on now-reserved words.
  • Run the following command to check the current level via query:
  SELECT compatibility_level FROM sys.databases WHERE name = 'YourDBName';

Step 4: Update Application Code and Stored Procedures

  • Search all stored procedures, views, and functions for usage of the reserved keyword using:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%YourKeyword%';
  • Refactor all instances to use bracketed identifiers or rename columns/objects entirely to avoid future conflicts.

Alternative or Verification Steps

  • Verify the fix by executing the corrected script in a test environment first; confirm no Error 156 appears in the Messages tab of SSMS.
  • If the issue persists across multiple objects, consider lowering the database compatibility level temporarily via ALTER DATABASE ... SET COMPATIBILITY_LEVEL = 160; as a short-term workaround while code is refactored.