[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

sql right padding zeros after decimal

Posted on 2011-03-14
2
Medium Priority
?
1,813 Views
Last Modified: 2012-05-11
Hi, I am trying to add right padding zeros to my decimal values but I get stuck.

So far I can add left padding zeros and remove the dcimal point,
the issue is that when I get a value of 2.43 then I can convert it to 000243 but if its 2.4 then the converision is to 000024. I need to modify the query so I can have such result:
000243
000240
etc..

 
SELECT RIGHT('0000000000' + CONVERT(VARCHAR,REPLACE([CustFinTrxnNetAmt], '.', '')), 10)  FROM [Transactions]

Open in new window


Thank you for your answer.
0
Comment
Question by:rkanabus
[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
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35128753
first, convert to varchar, then remove comma, finally left pad:
SELECT RIGHT('0000000000' + REPLACE( CONVERT(VARCHAR(10), CONVERT(DECIMAL(20,4), [CustFinTrxnNetAmt])) , '.', '') , 10)  FROM [Transactions]

Open in new window

0
 

Author Comment

by:rkanabus
ID: 35128778
Excellent, thank you!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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