Solved

add 0 value on select

Posted on 2010-11-22
3
327 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:Seven price
[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:Seven price
ID: 34188646
thanks
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

623 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