Sybase : How to remove leading zeros from a column?

This is how I do it:

UPDATE <tablename>
SET <column> = SUBSTRING(<column>, PATINDEX('%[^0]%', <column>), CHAR_LENGTH(<column>))
WHERE <column> LIKE '0%'

Obviously, the most interesting part for me is the:


construct that finds the position of the first non-ZERO character in the <column> to start substring from.

For detailed info about used functions, please visit Sybase’s documentation:



2 thoughts on “Sybase : How to remove leading zeros from a column?

    • Hi Ricky,

      You can use the same query. Give it a try. If it does not work, paste here your test data and I’ll try to help.


Leave a Reply to AspirantCoder Cancel reply

Your email address will not be published. Required fields are marked *