- Error number
- 156
- Severity
- 15 (user-correctable error)
- State
- 1
- Product
- Microsoft SQL Server Database Engine
- Versions
- All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
- Category
- Syntax & Object Resolution
- Last reviewed
- 23 October 2026
On this page
What it means
Error 156 means the T-SQL parser met a reserved keyword, such as FROM, ORDER or USER, in a place where the grammar does not allow it.
Error 156 is the keyword form of error 102. The parser was reading your batch, expected a name, value or another clause, and found a reserved word instead. The keyword is quoted exactly as you typed it ('FROM', 'User'), and the line number counts from the start of the batch. Nothing in the batch runs.
Read it in one of two ways. Either something just before the keyword is incomplete, so the keyword arrived too early (a trailing comma before FROM, an empty WHERE, clauses in the wrong order), or the keyword is really one of your names, such as a column called User or a table called Order, and needs square brackets.
Common causes
- A trailing comma at the end of the SELECT list, so the parser expects another column and meets
FROM. - A reserved word used as a column or table name without brackets:
User,Order,Group,Key,Table,Index. - Clauses in the wrong order, for example
WHEREbeforeFROM(fails near FROM) orGROUP BYafterORDER BY(fails near GROUP). - A clause left incomplete just before a keyword, such as
WHEREfollowed directly byGROUP BY. - Generated SQL that joins pieces with a separator and leaves an extra comma or AND before the next keyword.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Ask the engine which keyword it rejects, without running anything
sys.dm_exec_describe_first_result_set returns parse and binding errors as rows, so you can test a broken statement safely.
SELECT error_number, error_message
FROM sys.dm_exec_describe_first_result_set(
N'SELECT id, name, FROM dbo.Customers;', NULL, 0); A row with 156 and the keyword (plus a generic 11501 row) while the statement is broken; the output columns once it parses.
Find columns and tables whose names are reserved words
A shortlist of reserved words that often end up as names. Extend the list from the Microsoft reserved keywords page if your schema uses others.
SELECT o.type_desc, OBJECT_SCHEMA_NAME(o.object_id) AS schema_name, o.name AS object_name, c.name AS column_name
FROM sys.objects AS o
LEFT JOIN sys.columns AS c ON c.object_id = o.object_id
WHERE o.is_ms_shipped = 0
AND (o.name IN (N'User', N'Order', N'Group', N'Key', N'Table', N'Index', N'Function', N'Public', N'File')
OR c.name IN (N'User', N'Order', N'Group', N'Key', N'Table', N'Index', N'Function', N'Public', N'File'))
ORDER BY schema_name, object_name; Every object or column that must be written in square brackets in every query.
Generate a safely bracketed column list
SELECT STRING_AGG(QUOTENAME(name), N', ') WITHIN GROUP (ORDER BY column_id) AS column_list
FROM sys.columns
WHERE object_id = OBJECT_ID(N'dbo.Accounts'); A list such as [id], [User] that you can paste into the SELECT list.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Remove the trailing comma or finish the clause
Read-onlyLook just before the quoted keyword. Delete a comma that ends the list, or complete the condition that was left empty.
SELECT id,
name,
email
FROM dbo.Customers;
Bracket reserved words used as names
Read-onlySquare brackets make the parser treat the word as a name. Bracket it everywhere it appears, including CREATE TABLE and ORDER BY.
SELECT a.id, a.[User]
FROM dbo.Accounts AS a;
SELECT id, total
FROM dbo.[Order];
Write clauses in the required order
Read-onlyA SELECT is written in this order: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.
SELECT customer_id, COUNT(*) AS orders
FROM dbo.Orders
WHERE total > 100
GROUP BY customer_id
ORDER BY orders DESC;
Rename the column so it is no longer a keyword
Changes schemaThe long-term fix for a column you own. Renaming does not move data.
Caution:
Every query, view, procedure and application that uses the old name breaks after the rename. Search for references first and deploy the change together with the code that uses the new name.
EXEC sp_rename N'dbo.Accounts.[User]', N'user_name', N'COLUMN';
Examples
A trailing comma before FROM
CREATE TABLE dbo.Customers (id INT PRIMARY KEY, name NVARCHAR(100), email NVARCHAR(200));
GO
SELECT id,
name,
email, -- the parser now expects another column
FROM dbo.Customers;
Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'FROM'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
A column named User without brackets
CREATE TABLE dbo.Accounts (
id INT PRIMARY KEY,
User NVARCHAR(50) -- USER is a reserved keyword; write [User]
);
Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'User'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
A table named Order without brackets
CREATE TABLE dbo.[Order] (id INT PRIMARY KEY, total DECIMAL(10,2));
GO
SELECT id, total
FROM dbo.Order; -- the table exists, but Order is a keyword
Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'Order'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
How to prevent it
Do not use reserved words as table or column names: user_name, orders and order_group never need brackets. If a schema already has such names, have your query generator or ORM quote every identifier with QUOTENAME or square brackets.
Put each column on its own line with the comma at the start (, email) so a trailing comma stands out, and format queries with a tool such as the SQL formatter. The ORDER BY, GROUP BY and HAVING guide covers clause order.
Common questions
Why does SELECT User FROM my table not raise error 156?
USER is also a built-in function that returns the current database user name. SELECT User FROM dbo.Accounts runs and returns that name (for example dbo) on every row, not your column. Write a.[User] to get the column. Error 156 appears where the function is not allowed, such as in a column definition.
Is a missing comma between two columns error 156?
Usually not. SELECT name email FROM dbo.Customers runs without error: email becomes an alias for name. That silent mistake is why some teams always write AS before an alias.
Where is the full list of reserved keywords?
Microsoft publishes it as "Reserved keywords (Transact-SQL)", together with ODBC and future reserved words. Any of them can be used as a name if it is written in square brackets or, with QUOTED_IDENTIFIER ON, in double quotes.
Learn more on CodeWithSQL
Official documentation
- Reserved keywords (Transact-SQL)
- Database identifiers (Microsoft Learn)
- SELECT (Transact-SQL)
- Database Engine events and errors 0 to 999
Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.