DBAtlas · Database operations atlas

102: Incorrect syntax near 'token'

SQL Server

What does it mean?

The Transact-SQL parser found invalid syntax near the specified token and could not compile the statement. The query is rejected before it runs.

Why does it happen?

A typo, a missing comma/parenthesis, a reserved keyword (e.g. USER, ORDER) used without square brackets, an unterminated string literal, or incompatible syntax copied from another SQL dialect. Concatenation mistakes in dynamic SQL are also a frequent trigger.

How to fix it

Inspect the area around the reported token carefully; the error is often on the preceding line. Wrap reserved words in square brackets ([Order]) and check that parentheses and commas balance. If you build dynamic SQL, PRINT @sql to see the generated text and run it. Verify that the syntax is supported by the version/compatibility level.

Open in DBAtlas →

More from this engine