Is there any string manipulation function which allows me to trim nonspace characters? I need to trim leading zeros from item codes, for example '000012KV' -> '12KV'. Converting to integer does not work because there are alphabtic characters in the item code field. |
There is no direct function to do this for you, but you can accomplish it using patindex and substr. Example:
gives
so wrapping it altogether you would use
If you want, you can put this expression in a function and SQL Anywhere will automatically inline the function into your query (provided the function is a one-liner) when you use it:
|
I think that Mark's solution is the cleanest, although I would make it more generic:
Is there a way to modify it to remove trailing chars? |
You can use patindex to find the first character that is not the 0.
Thomas |