Solved

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

Posted on 2008-06-18
4
2,085 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Dave Ford
Dave Ford 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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