How to remove the leading zero's.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
stiwari
Participant
Posts: 64
Joined: Wed Apr 05, 2006 3:45 am

How to remove the leading zero's.

Post by stiwari »

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
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Use Trim() function. Or Convert() if you think, 0's will be only in leading end.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSbox61
Premium Member
Premium Member
Posts: 62
Joined: Mon May 22, 2006 10:18 am

Post by DSbox61 »

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... :roll:
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Post by meena »

Hi,
Try this:

Code: Select all

Trim ("000876 and 000etywe",'0',L)
L:-Removes leading occurrences of character.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
Post Reply