Format select statement to pad text with leading zeros

Hello,

What is the code used to format a field selected so that it always has a fixed number of characters (i.e., padded with leading 0s for a total length of 10)?

Example for Field1:

Actual                   Desired
123                        0000000123

Thanks,
SASnewbie
SASnewbieAsked:
Who is Participating?
 
Atdhe NuhiuCommented:
concat is MySQL not MS sql

select RIGHT ('0000000000'+field1,10 ) from table
0
 
Atdhe NuhiuCommented:
something like

select RIGHT ('0000000000'+field,10 ) from table
0
 
SASnewbieAuthor Commented:
Here is a sample of my select statement that I have tried:

SELECT    Client, right(concat("0000000000", Field1),10) as Loan_num,  Result
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
SASnewbieAuthor Commented:
Hi andycrofts,

I'll try that and get right back to you,

Thanks!
0
 
SASnewbieAuthor Commented:
Thanks! That works perfectly!
0
 
Atdhe NuhiuCommented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.