maak Posted May 12, 2008 Report Share Posted May 12, 2008 Hi I'm new to SQL and i'm facing with following error: using "Example - Insert into a Table.vi" to add a record in Access2000 DB composed by only one table named "Section" with one numeric field named "ID". When I run vi with following Command Text "INSERT INTO Section VALUES (1)" get this error code "-2147217900 Exception occured in Microsoft JET Database Engine. Syntax error in instruction INSERT INTO". Now I change the name of the table from "Section" to "AAAA" (but any other name is fine) and with the same command (replacing only table name) the error disappear and the values are correctly writed!!! Seems that "Section" is not a valid name for a table using LabSQL...or i'm missing something, i'm not experienced with SQL. I cannot change the name of tables in DB because are used from other programs. thanks for help Maak Quote Link to comment
orko Posted May 12, 2008 Report Share Posted May 12, 2008 QUOTE (maak @ May 11 2008, 02:01 PM) "INSERT INTO Section VALUES (1)" Yes, "SECTION" is a reserved word in ODBC land. http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx' rel='nofollow' target="_blank">Here is a good reference to all the "taboo" words that should not be used as table/field names. Note that even though Access doesn't have a problem with "Section", it is the ODBC driver that rejects it because it is reserved. Even though these reserved keywords should not be used, they can be worked around by using brackets to surround the table name, like this for example: "INSERT INTO [section] VALUES (1)" or even better: "INSERT INTO [DBName.tablename] VALUES (1)" Hope this helps you out. Quote Link to comment
maak Posted May 13, 2008 Author Report Share Posted May 13, 2008 QUOTE (orko @ May 11 2008, 10:21 PM) Even though these reserved keywords should not be used, they can be worked around by using brackets to surround the table name, like this for example:Hope this helps you out. the brackets is all what I need :thumbup: thanks Quote Link to comment
Rolf Kalbermatter Posted May 14, 2008 Report Share Posted May 14, 2008 QUOTE (maak @ May 12 2008, 02:29 AM) the brackets is all what I need :thumbup: thanks It's good practice to always use brackets around table names and column identifiers. This will not only catch reserved words but also identifiers that have embedded spaces, which for SQL is a syntax separator otherwise. Rolf Kalbermatter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.