Page 1 of 1

Leading Zeros

Posted: Tue May 08, 2012 9:47 am
by edison
Input is a txt file and output table.

Input

0001
0002
0003
0001,0002
0005
0003,0004

Need out put like

01
02
03
01,02
05
03,04

Posted: Tue May 08, 2012 10:55 am
by chulett
Investigate the FMT() function if we are talking about string fields here. What is the datatype of these columns in the target table?

Posted: Tue May 08, 2012 4:08 pm
by ray.wurlod
The FMTS() function will be of even more use.

Code: Select all

Convert(@VM,",",Fmts(Convert(",",@VM,InLink,TheString),"2R"))
The inner Convert() changes commas to value marks.
The Fmts() function applies the format specification to each value in the multi-valued field.
The outer Convert() changes the values marks back to commas.

Posted: Tue May 08, 2012 4:29 pm
by chulett
FMTS... plural? Not familiar with that one or at least it's not ringing a bell, need to look it up later, it would seem. :?

Posted: Tue May 08, 2012 6:56 pm
by ray.wurlod
Plural = multi-valued, yes.

Posted: Tue May 08, 2012 8:24 pm
by chulett
Ah, I see...