Avatar of jsctechy
jsctechy
Flag 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
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
jsctechy

8/22/2022 - Mon
SOLUTION
chapmandew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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

jsctechy

ASKER
Copy and paste was a key!
Thanks
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23