What it means
SQL Server parses a whole batch before running any of it. Error 156 means it reached a reserved word,
such as FROM, WHERE, ORDER or IF, at a point where that word can’t come next. The batch is
rejected and nothing in it runs.
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'FROM'.
The keyword in quotes is where parsing stopped, not necessarily where the mistake is. Look at what
comes right before it: SELECT id, name, FROM fails at FROM because of the comma before it. When the
unexpected text isn’t a reserved word, the same mistake is reported as
error 102, Incorrect syntax near '…'.
Common causes
-
A comma too many, or missing.
SELECT id, name, FROM …andUPDATE … SET name = N'x', WHERE …. -
A reserved word used as a name. A column or table called
order,key,file,plan,desc,user,grouportablefails unless you put it in brackets. (status,date,name,type,value,textandlevelare fine.)useris a trap of its own: unbracketed in aSELECT, it doesn’t fail but returns the current database user’s name instead of the column. -
Syntax from MySQL or PostgreSQL that T-SQL doesn’t have:
Written Error on SQL Server T-SQL CREATE TABLE IF NOT EXISTS t …156 near 'IF'IF OBJECT_ID(N't', N'U') IS NULL CREATE TABLE t …ALTER TABLE t ADD COLUMN c int156 near 'COLUMN'ALTER TABLE t ADD c intDELETE FROM t AS x WHERE …,UPDATE t AS x SET …156 near 'AS'DELETE x FROM t AS x WHERE …,UPDATE x SET … FROM t AS xINSERT … ON DUPLICATE KEY UPDATE …156 near 'ON'MERGE, orUPDATEthenINSERT … WHERE NOT EXISTSIF x THEN … END IF156 near 'THEN'IF x BEGIN … ENDCASE … END CASE156 near 'CASE'CASE … END… JOIN t2 USING (id)102 near 'USING'JOIN t2 ON t2.id = t1.id -
A missing part of a clause. A
JOINwithout itsON(156 near'WHERE'), or a subquery inFROMwithout an alias:SELECT * FROM (SELECT …) WHERE …fails near'WHERE'. -
DROP TABLE IF EXISTSon an old server. It needs SQL Server 2016 or later; older versions reject it as a syntax error.
How to fix it
Read what comes before the keyword
Find the keyword in the line SQL Server reports (lines count from the start of the batch) and look at
the token before it: a comma at the end of a list, a missing ON, a subquery that needs AS t.
Bracket names that are keywords, or rename them
CREATE TABLE dbo.order_items (id int PRIMARY KEY, [order] int NOT NULL, [key] varchar(20));
SELECT [order], [key], [user] FROM dbo.order_items;
Double quotes work as well while QUOTED_IDENTIFIER is on, as it is for most connections (sqlcmd
turns it off unless you pass -I). For a new table, choose names that aren’t keywords (order_id,
api_key); Microsoft’s list of reserved keywords also names words that may become reserved in
future versions.
Translate the other dialect
Use the T-SQL column of the table above. For example, a derived table needs an alias, and an
UPDATE through a join takes a FROM:
SELECT t.id FROM (SELECT id FROM dbo.customers) AS t WHERE t.id = 1;
UPDATE c SET name = N'Ada L.'
FROM dbo.customers AS c
WHERE c.id = 1;
Reproduce it
On SQL Server 2022 (16.0.4295.3) with sqlcmd, in a scratch schema, each statement in its own
batch:
SELECT id, name, FROM seo_err_mssql.customers;
CREATE TABLE seo_err_mssql.t156 (id int, order int);
SELECT key, value FROM seo_err_mssql.customers;
SELECT c.id FROM seo_err_mssql.customers c JOIN seo_err_mssql.orders o WHERE o.customer_id = c.id;
CREATE TABLE IF NOT EXISTS seo_err_mssql.t156 (id int);
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'FROM'.
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'order'.
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'key'.
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'WHERE'.
Msg 156, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Server 7732422b7f56, Line 1
Incorrect syntax near 'seo_err_mssql'.
The other rows of the table above gave the errors shown there, and IF 1 = 1 THEN SELECT 1; END IF;
gave 156 twice, near 'THEN' and near 'IF'. Columns named file, plan, desc, group,
table and user failed near those keywords; a table with columns status, date, type, name,
value, level, text and timestamp was created without complaint. In a table with a column [user] holding ada,
SELECT user, [user] returned inlet and ada. With brackets, [order], [user] and "key" all
worked. SQL Server 2019 and 2025 printed the same messages.
In Inlet
The query editor highlights keywords as you type, so a column named order stands out before you run
it, and its completion offers names from the live schema. Query tabs run T-SQL a batch at a time,
splitting at GO. When SQL Server rejects a batch, Inlet shows its message with
SQL Server error 156, state 1, severity 15 and links to this page. With your own Anthropic API key,
Ask Claude (Pro, ⌘L) writes T-SQL, so it can translate a MySQL or PostgreSQL statement; it sends the
schema and the SQL, never rows.