Hi All,
I have to remove leading zero's from a varchar field....the scenario is like...i have the value's like 000876 and 000etywe now i have to remove the leading from only those records where it follows numeric value after the zero's....
It should be 876 and 000etywe
can any one tell me how to do this??
Thanks in advance
stiwari
How to remove the leading zero's.
Moderators: chulett, rschirm, roy
to remove leading zeros..it is straight forward..u need to use Trim function...but to decide where to to use that function based on ur condition, u need to use If then else statement and another function Num with it....this function num will return 1 if the given string can be converted to a number...
hope this helps...![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
hope this helps...
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
Hi,
Try this:
Try this:
Code: Select all
Trim ("000876 and 000etywe",'0',L)
L:-Removes leading occurrences of character.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
And the other part of the requirement is a simple If..Then..Else
Code: Select all
If Num(InLink.TheColumn) Then Trim(InLink.TheColumn, "0", "L") Else InLink.TheColumn
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.