Solved

add 0 value on select

Posted on 2010-11-22
3
326 Views
Last Modified: 2012-05-10
i have a column that has quantity's in it but if my quantity  is a one digit then add 0 in front this works
example
5 below makes it 05 or 8 makes it 08 and it leaves it if it is 55 or 88.

right('0'+convert(varchar(3),DOD.Quantity),2)

But the problem if there is a 3 digit quantity and the  quantity for example is 323 it will only display 23, I do not want to increase the 0 because I do not want it to turn out 055 or 023.

I just need if one digit add 0 in front else more than one digit then do not add 0's
0
Comment
Question by:sevensnake77
[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
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34188625
select case when DOD.Quantity < 10 then '0' else '' end + cast(DOD.Quantity as varchar(20))
0
 
LVL 13

Expert Comment

by:Rick
ID: 34188641
IF value < 10 THEN
right('0'+convert(varchar(3),DOD.Quantity),2)
ELSE END as 'Column Name'
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 34188646
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

710 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