In ArcMap, an SQL query performed on an attribute table to select a particular set of digits from a field is not possible.
A wildcard query is used to substitute any other character in a string. When a wildcard query is carried out using an attribute query, the following error is returned:
Error: An invalid SQL statement was used.
The error is returned during the verification of the expression.
This issue occurs when a wildcard query is carried out on a numerical field using an expression such as the one displayed below.
FIELD LIKE '42041%'
Wildcard symbols such as the percent sign and the asterisk can only be used in a string field.
There are two options to perform a wildcard query on an attribute table.
If the first option cannot be carried out, apply the second.
Use the CAST function in the attribute table
In this example, the CAST() function converts the field to a string of characters to allow the wildcard query on the number field.
CAST(Field_Name AS VARCHAR(12)) LIKE '323%'
Note: VARCHAR denotes the character length and must be specified when using the CAST function.
Create a new string field, and compute the old field to the new field
New_Text_field LIKE '324%'
Get help from ArcGIS experts
Download the Esri Support App