Search code examples
sybase

parsing in sybase a fields with different digits


i have a field on sybase for a particular table where i need to select only the first value. See the example below:

Field1
104676;ABC;345776;TEST
2332;ABC;345776;TEST
8765432;ABC;345776;TEST

This particular field have char format. I want to pullout only the first value (starting from the left) that is compost by different number of digits, in particular:

Field1
104676
2332
8765432

in conclusion i need to formart the field in numeric and pullout only the first value. thanks id advance for your help.


Solution

  • I guess you may easily pull this using SUBSTRING/CHARINDEX function combination -

    SELECT SUBSTRING(Field1, 1, CHARINDEX(';', Field1) -1)
    FROM YOUR_TABLE