Page 1 of 1

How to PAD with Leading Zeroes

Posted: Thu Oct 05, 2006 11:27 am
by ambasta
Hi All,
Can anyone please help me..
Source is having Varchar(10) and target is Char(10).My Requirement is...
any length of data till length 10 can come from source,and i need to pad this data with leading zeroes followed by that data so that length in target side is remain 10.
Ex.
if data is coming like 12345 then populate 0000012345,
if data is coming like 432 then populate it as 0000000432.
if data is coming like 1234567 then populate it as 0001234567.

Please help me.

Posted: Thu Oct 05, 2006 12:02 pm
by ArndW
I can think of a couple of approaches in a transform stage using string functions.
One would be

Code: Select all

STR('0',10-Len(In.String)):In.String
or

Code: Select all

RIGHT('0000000000':In.String,10)
to name just two methods.

Re: How to PAD with Leading Zeroes

Posted: Thu Oct 05, 2006 12:11 pm
by meena
Hi,
Try this FMT("input column", "10'0'R").
Source is having Varchar(10) and target is Char(10).My Requirement is...
any length of data till length 10 can come from source,and i need to pad this data with leading zeroes followed by that data so that length in target side is remain 10.
Ex.
if data is coming like 12345 then populate 0000012345,

Posted: Thu Oct 05, 2006 12:11 pm
by ambasta
Thanx a lot ArndW for this kind help.
This is working for me.

Posted: Thu Oct 05, 2006 2:36 pm
by ray.wurlod
Is FMT function available in parallel jobs?

Posted: Thu Oct 05, 2006 3:01 pm
by ambasta
Hi Ray,
i can't find any function called FMT in parallel jobs.I think it is not available.