Reserved Keywords Transact SQL

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury, Rain

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3276
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Reserved Keywords Transact SQL

Post by JRL » Mon Jul 24, 2017 9:07 pm

I just spent a couple of hours trying to figure out why my Update SQL was failing. The only error I received said:

Error in : update attempt
Line: 14 - Syntax error in UPDATE statement

Excruciatingly vague.

After making many web searches and trying many combinations of quotes and apostrophes I finally discovered that two of the table names in the Excel file I was updating were reserved words. "Left" and "Top" can't be accessed in an update SQL. Here's a Microsoft web page with all reserved words.

https://docs.microsoft.com/en-us/sql/t- ... ansact-sql


Odd thing is there is no failure using those same column names when I do a query of the same Excel file.

AND... Yes, I know I could save myself the headache if I simply used the Macro Scheduler Excel functions. Problem is I vacillate between capturing data from Excel and data from our Pervasive database so writing scripts using only ODBC makes things consistent. I have written update scripts before, apparently got lucky enough not to stumble over the reserved words prior to today.

Post Reply