Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

EDIT:

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.

Thanks.

share|improve this question
    
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
add comment

1 Answer

up vote 2 down vote accepted

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'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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