DBAtlas · Database operations atlas

156: Incorrect syntax near the keyword

SQL Server

What does it mean?

There is a syntax error near a keyword. SQL Server could not parse the statement because a reserved word is used in an unexpected position.

Why does it happen?

Using a reserved word (e.g. ORDER, USER, TABLE) as a column/object name without brackets, a missing comma/parenthesis, clauses in the wrong order, or a misplaced clause (WHERE, GROUP BY).

How to fix it

Inspect the area around the keyword the error points to. If you use reserved words as object names, wrap them in square brackets (e.g. [User]). Fix missing commas, parentheses, and clause order. Test the syntax by breaking the query into parts.

Open in DBAtlas →

More from this engine