Friday, November 25, 2011

SQLSTATE=42601

 I was in need to fetch top n rows from a particular table in DB2. I got below mentioned error when tried with some incorrect syntax.

 42601(-104)[IBM][CLI Driver][DB2/SUN64] SQL0104N  An unexpected token "1" was found following "Select TOP ".  Expected tokens may include:  "".  SQLSTATE=42601
 (0.45 secs)

Correct Syntax :

Select * from table_name where filed = 'Some condition' order by field FETCH FIRST 10 ROWS ONLY;