Hi, I have a link server from SQL connect to AS400 configured to run OPENQUERY to retrieve data from AS400. I encountered "Incorrect syntax near BEER" syntax error from SQL SSMS. I can't figure out why this simply condition would give me an error. If I remove the WHERE DEPARTMENT = ''BEER'' condition, it retrieve data from AS400 with success. Does anyone know how to correct below syntax error? SELECT * FROM OPENQUERY(AS400,' SELECT DEPARTMENT, CLASS FROM MYLIB.WORKTBL01 WHERE DATE = 20171217 AND DEPARTMENT = ''BEER'' ') Msg 102, Level 15, State 1, Line 7 Incorrect syntax near 'BEER'.
Date on the AS400 side is defined as numeric which is fine without quotes. I figured out the issue which is related to the SQL parser side. I put triple single quotes before and after BEER resolved the issue. Thanks for looking into this for me. I am all good now.