SQL Server engine errors
SQL Server 102 Incorrect syntax near
Incorrect syntax near — a Transact-SQL syntax error was detected at the specified token
What 102 Means
The 102 error on the SQL Server engine errors indicates incorrect syntax near — a transact-sql syntax error was detected at the specified token. This typically occurs due to typo or missing keyword in a t-sql statement.
Error 102 is a parser-level error returned before any query execution begins. The error message includes the specific token near which the syntax failure was detected.
Technical Background
SQL Server parses the entire T-SQL batch before execution. When a syntax rule is violated, the engine raises error 102 and includes the token that triggered the failure.
The token in the error message is not always the actual mistake — it marks where the parser gave up. The real error is often a line or two earlier.
Common Causes
- Typo or missing keyword in a T-SQL statement
- Reserved word used as an identifier without bracket quoting
- Unmatched parentheses, quotes, or BEGIN/END blocks
Typical Scenarios
- Stored procedure with a missing comma between column names in a SELECT list
- Dynamic SQL string with an unescaped single quote breaking the statement
- Using a reserved SQL keyword such as ORDER as a column name without wrapping it in square brackets
What to Know
Error 102 is always a query authoring problem detected at parse time, before any execution occurs. The parser reports the token where it failed, which is not always the actual mistake — a missing comma or keyword earlier in the statement often causes the failure to surface at a later token.
Frequently Asked Questions
Common questions about SQL Server 102 error
The parser reports the token where it failed, not necessarily where the mistake is. A missing comma earlier in the query causes the parser to reach an unexpected token further along.