Page 1 of 1

truncate trailing zeroes

Posted: Tue Feb 07, 2006 8:35 pm
by edward_m
My sequential file looks like ..
col1 col2 col3
1 100100 123
2 200000 234
3 199900 245
4 329800 424
5 345000 125
6 234500 235

I want to convert this file to..
col1 col2 col3
1 1001 123
2 2000 234
3 1999 245
4 3298 424
5 3450 125
6 2345 235

i.e i need to supress last two zeroes in col2 and load into target.
I used the trim(col2,"0","T"),its taken out all trailing zeroes..
Please guide me how to takeout last two zeroes from col2.

Thanks

Posted: Tue Feb 07, 2006 8:42 pm
by rasi
Simple answer is to divide your number by 100

Ans = Int(Input_Value/100)

eg. 1. 348500/100 = 3485
2. 87912/100 = 879

Posted: Tue Feb 07, 2006 8:54 pm
by edward_m
rasi wrote:Simple answer is to divide your number by 100

Ans = Int(Input_Value/100)

eg. 1. 348500/100 = 3485
2. 87912/100 = 879
Thanks for your quick reply.My column col2 is varchar datatype.
Please guide me ..

Posted: Tue Feb 07, 2006 9:08 pm
by rafidwh
Try this

Oconv(columnname, " MR2 " )

I hope U will get

Posted: Tue Feb 07, 2006 9:10 pm
by rasi
use this Input_Value[1,Len(Trim(Input_Value))-2]

This will give you the result

Posted: Wed Feb 08, 2006 12:06 am
by Sunshine2323
Hi Edward,

Substrings(Source.Col,1, Len(Source.Col)-2)

Left(Source.Col,Len(Source.Col)-2)

I am sure there are many more ways of achieving the result.

Posted: Wed Feb 08, 2006 5:32 am
by raj_konig
even a direct substring function will get this.

substring(col2, 1,4)

raj

Posted: Wed Feb 08, 2006 8:51 am
by I_Server_Whale
Much more simpler would be:

Your derivation becomes:

Code: Select all


col2[1,4]


Posted: Wed Feb 08, 2006 10:43 am
by edward_m
Thanks a lot for all.

Posted: Wed Feb 08, 2006 11:05 pm
by ray.wurlod
There are no actual data types within server jobs. Dividing by 100 was a perfectly valid method. So is substring (or Left() function).