Are Def Query using SQL now different?

651
9
06-17-2019 12:55 PM
DougBrowning
MVP Esteemed Contributor

I am trying a simple query to look for accidental lower case errors.  For example Pf098788 should be PF098788.

I made a simple query UPPER(UnknownCode) <> UnknownCode and I get no results.  If I try UPPER(UnknownCode) = UnknownCode I get everything.

Layer us a AGOL Hosted feature service.

What am I missing here?

Thanks

0 Kudos
9 Replies
JoshuaBixby
MVP Esteemed Contributor

You have tried this against AGOL hosted feature services in the past and it worked?

0 Kudos
DougBrowning
MVP Esteemed Contributor

Nope never tried this exact query.  Used others just fine though.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Not to ask the obvious, but you know there are accidental lowercase records? 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yea I have been manually changing them all day.  My guess is UPPER is not working right since if I use = it gives me AF and Af back.  <> I get 0 records.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I just did some testing and see what you mean.  I don't think the issue is UPPER because if I do something like UPPER(field) = 'XYZ', I get 'xyz' and 'XYZ' returned.  I think the issue has something to do with referencing the field on the right-hand size of the SQL statement.

0 Kudos
MarisaClaggett
Occasional Contributor II

Hi Doug,

Are you doing this calculation via ArcGIS Pro or in AGOL?  In AGOL, the calculation for SQL is simply UPPER(<field name>).

I used the following example SQL to calculated the hosted feature layer field in Pro as well.

UPPER(NOTES)

If using Select by attributes, I can certainly see the issue.  

Best of luck,

Marisa

0 Kudos
DougBrowning
MVP Esteemed Contributor

Not a field calc - this is a Def Query.  

I did notice it keeps defaulting to SQL for field calc, which is weird.  Is there a setting to make this default to Python.

0 Kudos
ThaddeusBara
New Contributor

By definition, SQL Server is case insensiitve.  Is that perhaps what you are missing?

0 Kudos
DougBrowning2
Occasional Contributor III

If you Def Query a SQL server then yes.  If you Def Query a GDB then no it is case sensitive.  The backend of AGOL is neither i think.  I could see that it may act that way though.  If I try to use COLLATE Latin1_General_CS_AS it says invalid SQL.

0 Kudos