Issue with queryTask and SQL Reserved Keywords

Discussion created by crombezk on Jan 23, 2011
Latest reply on Sep 26, 2011 by cshore11
I ran into an interesting issue using the queryTask and thought I would post my findings in hopes it can save someone else the coding heartache I just went through.

We pull data tables into SDE from the County's AS400.
One of the data tables I was performing a query on had a SQL reserved keyword used as an field name. When including the conflicting field name in the query.outFields; the query fails. This is also the case when trying to use query.outFields = ["*"];

In my example, the conflicting field name was ALL.
using query.outFields = ["ALL"]; failed
using query.outFields = ["*"]; also failed

not setting query.outFields to anything, works!

The errors produced:

Code 100005: Method failed. HRESULT = 0x8004152f : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT.

Code 10837: General GeoDatabase Error.

Code 10837: Geodatabase error: Invalid SQL syntax [Microsoft SQL Server Native Client 10.0: Incorrect syntax near the keyword 'ALL'.] [Server.DataBase.TableName].

Solution: Do not use SQL reserved keywords for field names. Now we simply rename the field when pulling the table into SDE.

Happy Debugging!