Error: An invalid SQL statement was used
In ArcMap, when attempting to display X and Y coordinate data in a table from a CSV file, the following error occurs.
Error: An invalid SQL statement was used.
This error occurs due to one of the following reasons.
- Not exporting the X, Y event layer permanently after adding the X and Y coordinate data to the map.
- Proper formatting rules are not adhered to when naming the X and Y coordinate fields.
- The X and Y coordinate fields have text set as the data type, instead of a numeric data type.
Solution or Workaround
There are three possible solutions for this issue, depending on the cause.
- Make the X, Y event layer permanent by saving the X and Y coordinates data as a shapefile in a project folder, or as a feature class in a file geodatabase. When the X and Y coordinate data is added to the map, it becomes an X, Y event layer. In ArcMap, event layers are designed to be temporary, which means that the event layers defined during a session do not persist after the session ends.
- Comply with formatting conventions when naming the fields to ensure ArcMap recognizes the field names set in a table to display the X and Y coordinate data. Reserved words cannot be used as field names, and field names must start with a letter and can only contain letters, numbers and underscores without any spaces.
- Convert the X and Y values to decimal degrees, and store the values as a numeric field because coordinate value is recognized as numeric data. For more information, refer to: ArcGIS Resources: Adding x, y coordinate data as a layer.