[SalesForce] Batch Apex to trim leading zeros

Can I write a batch apex to trim leading zeros from couple of fields. There are 2 number fields with around 1 million records with leading zeros.

Batch apex or any other way? Which should be much faster?
Also do we have any apex methods that would handle the trimming part.

Thanks.

Best Answer

You could do this through a formula field or workflow field update also. if Raw_Number__c is your numeric Text field, this would be the formula for the same number with no leading zeroes:

TEXT( VALUE( Raw_Number__c ) )
Related Topic