Solved

How do I Zero Fill a Result when I have a REPLACE Function in the Query

Posted on 2012-03-14
2
435 Views
Last Modified: 2012-06-21
So, this is the last part of my Query where It pulls up the Amount the Check is for, removes the Decimal, but I need it to be Zero Filled to the Left up to 10 Digits.

This is the Part of the Query I have so far.
REPLACE (CAST(checknet AS VARCHAR(20)), '.',  '')

When the Result comes back, it will come back as follows:

0001234567890010000029974201202281833329

The very last part of that you will see 1833329 That is the check amount of $18,333.29

Because that is only 7 Digits, I need 3 Zero's to fill to the Right.

Thanks again for all of your guy's help!
0
Comment
Question by:Rmumpower00
2 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 37721372
Howdy....

Use exactly the same technique that you used for the check number


  RIGHT ('0000000' + REPLACE (CAST(checknet AS VARCHAR(20)), '.',  ''), 7)


Good Luck,
Kent
0
 

Author Closing Comment

by:Rmumpower00
ID: 37721403
Kent,
You are the man!  Thank you
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Detach & Attach 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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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