AnsweredAssumed Answered

ArcGIS 10.2 - SQL syntax with quote in Python to build a layer?

Question asked by Vincenty on Feb 2, 2015
Latest reply on Feb 3, 2015 by Vincenty



I have a python tool in which an SQL query string make a layer:


"NAME " + "LIKE " + "'" + strField_NAME + "'"


However, it appears that I have some names containing quotes in my dataset! For example, Jimmy's Peak containing a single quote and thus crashing my script...


Is there any sort of escape character I could use in a Python script in order to build an SQL query?


For the time being, the query builds as NAME LIKE + 'Jimmy' because the name contains a single quote... and it should be NAME LIKE + Jimmy's Peak