5

I would like to use the CAST function in the definition query property of a layer and/or in the label class sql query window.

This was the most promising link that I've found, including the two links found there.

I haven't tried whether the syntax showed works against a file gdb but it doesn't work on SDE.

Anyone have luck using sql in ArcMap 10 against ArcSDE 10? Thanks.


This worked on sde when the field is a Double.

CAST(MP AS CHARACTER(12)) LIKE '7%'

It does work but '%5' doesn't work. Having the percent after works and before doesn't.

3
  • You may want to post your current syntax so we can pick it apart and look for errors. For example, file geodatabases use quotes around field names, personal geodatabases use brackets, and SDE doesn't use anything around field names.
    – Baltok
    Aug 22 '12 at 15:45
  • What is the underlying DBMS?
    – blah238
    Aug 22 '12 at 18:48
  • SQL Server 2008
    – Justin
    Aug 22 '12 at 19:20
2

I don't have a SQL Server instance to test with but try the LEFT or RIGHT functions, e.g.:

To get the first character:

LEFT(CAST(MP AS CHARACTER(12)), 1) = '7'

To get the last character:

RIGHT(CAST(MP AS CHARACTER(12)), 1) = '7'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.