Solved

What function to use to left pad a number with 0's

Posted on 2008-06-18
4
2,079 Views
Last Modified: 2008-09-17
I have a total count being retrieved into a variable in a stored procedure.
Example the value of the variable is an INTEGER datatype with value as 99.... I need to change the value as a char and use it as 000099 and create a string with tis number and more numbers.

99 should be changed to 000099 in characters.
0
Comment
Question by:boppanak
4 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 250 total points
ID: 21817282
you can use

select right(digitis(your_column_name),6)
0
 
LVL 18

Assisted Solution

by:daveslash
daveslash earned 250 total points
ID: 21817401

Momi's solution is BY FAR the easiest. Use it.

If you want something a little more flexible, you could use the to pad with any character:

select right(repeat('*', 6) || yourColumn,6)
... or ...
select right(repeat('0', 6) || yourColumn,6)

HTH,
DaveSlash
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now