Link to home
Start Free TrialLog in
Avatar of jsctechy
jsctechyFlag for United States of America

asked on

add leading zero to a column

hi,
I have this select statement:
Select MILLAGE_CODE FROM TAX_ROLL
and this returns this:
700  
1100  
1840  
950  
950  
750  
2000  
2000  
1000  
1000  
2200

what i need to do is add as many leading zero as requiered to make it 5 characters long as follows:
00700  
01100  
01840  
00950  
00950  
00750  
02000  
02000  
01000  
01000  
02200  

how can i do this?
Thanks,
jsctechy
SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bmilli
bmilli

Use the right function prepending the column with '00000'

select right ('00000' + '500',5)
so, this should work for you
Select right ('00000' + MILLAGE_CODE,5) FROM TAX_ROLL

Avatar of jsctechy

ASKER

Copy and paste was a key!
Thanks