# SQLCODE -199: Illegal use of a keyword

Source: https://wndsoftware.com/mainframe-errors/sqlcode-199

### SQLCODE -199: Illegal use of a keyword

SQLCODE -199 (SQLSTATE 42601) is a syntax error. Db2 found an SQL keyword where the grammar doesn't allow one, and the message lists tokens it expected at that point instead.


#### Other names for this code

Also written as `SQL -199`, `SQLCODE=-199`, `SQLCODE = -199`, `db2 -199`, `sqlstate 42601`, `SQL0199N`, `illegal use of keyword`.


### What it means

-199 is a close relative of -104. Both mean the statement breaks the SQL grammar, and both use SQLSTATE 42601. With -199 the word that stopped Db2 is a keyword, such as FROM, WHERE, ORDER or AND. The keyword is fine on its own, but it can't appear where it is. The message names it and gives a list of tokens that would have been acceptable.

As with -104, the mistake is often just before the keyword. A missing operand, a missing comma or a clause in the wrong order makes the next keyword look out of place.

Reserved words cause a second kind of -199. If a table or column has a name that is also an SQL keyword, using it without double quotes can make Db2 read it as the keyword.


### Common causes

- Clauses in the wrong order, such as ORDER BY before WHERE or GROUP BY after ORDER BY.
- A missing operand before a keyword, as in `WHERE STATUS = AND DEPT = 'A00'`.
- A keyword repeated or left over after an edit, such as `WHERE WHERE` or a trailing AND.
- A name that is also an SQL reserved word, used without double quotes.
- Syntax from another database product, where a keyword is valid in a position Db2 for z/OS doesn't support.


### How to find the problem

- Read the keyword and the expected tokens in the `DSNT408I` message or SQLERRMC.
- Look at the text just before the keyword. Check that the previous clause is complete and the clauses are in the right order.
- If the keyword is really a table or column name, check the list of reserved words in the SQL Reference for your release.
- For SQL built by a program, print the exact text Db2 received. Generated SQL often leaves a dangling AND or comma when a condition is empty.


### How to fix it

- Put the clauses in the order Db2 expects, and complete any expression that is missing an operand.
- Remove duplicated or leftover keywords. In programs that build SQL, add AND or a comma only between conditions, never after the last one.
- Put names that are reserved words in double quotes, in uppercase, or better, rename the object.
- Rewrite syntax from other products in Db2 for z/OS form.


### IBM documentation

[IBM documentation: -199](https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=codes-199). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -104 Illegal symbol in the statement Read →](https://wndsoftware.com/mainframe-errors/sqlcode-104)
[SQLCODE -007 Illegal character in the statement Read →](https://wndsoftware.com/mainframe-errors/sqlcode-7)
[SQLCODE -010 String constant not terminated Read →](https://wndsoftware.com/mainframe-errors/sqlcode-10)
[SQLCODE -206 Column name not valid Read →](https://wndsoftware.com/mainframe-errors/sqlcode-206)

### Questions


#### What's the difference between -199 and -104?

Both are syntax errors with SQLSTATE 42601. -199 names a keyword that is out of place. -104 is the general syntax error, and its token can be any symbol, a keyword included.


#### Can a column name cause -199?

Yes, if the name is also a reserved word and isn't in double quotes. Db2 reads it as the keyword and the statement no longer parses.


#### Is it the same on Db2 for LUW?

SQL0199N has the same SQLSTATE, 42601. The LUW message says the use of a reserved word is not valid and shows the text before it.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE -181](https://wndsoftware.com/mainframe-errors/sqlcode-181) · [SQLCODE -203](https://wndsoftware.com/mainframe-errors/sqlcode-203)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
