Advertisement

03.08.2008 at 12:31PM PST, ID: 23225652
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Padding a numeric field

Tags: Microsoft, SQL Server, 2005, T-SQL
HI Guys, I have a question. I have to output 2 implied decimal amount fields (AJ_Dollar_Amount & AJ_Amount). I have defined they as decimal (13, 0) and decimal (17, 0) respectively. I was told to use the following func to pad the field, but it is not working. How should I define field(s) or rewrite the Cast statement to get it to work?

Right('0000000000000' + Cast(AJ_Dollar_Amt as varchar (13)), 13),

Thank you,
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: Trudye
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
Views: 99
Translate:
Loading Advertisement...
03.08.2008 at 12:38PM PST, ID: 21078535

Rank: Savant

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.08.2008 at 12:55PM PST, ID: 21078595

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.08.2008 at 01:16PM PST, ID: 21078669

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.09.2008 at 12:47AM PST, ID: 21080693

Rank: Savant

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 03:25AM PDT, ID: 21085138

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 04:00AM PDT, ID: 21085273

Rank: Savant

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 04:09AM PDT, ID: 21085315

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 04:15AM PDT, ID: 21085338

Rank: Savant

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.10.2008 at 05:03PM PDT, ID: 21091786

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.08.2008 at 12:38PM PST, ID: 21078535

Rank: Savant

the function shall be working.
what is "wrong"?
 
03.08.2008 at 12:55PM PST, ID: 21078595

Rank: Sage

As long as you're not inserting the value into a numeric field this should display just fine.
 
03.08.2008 at 01:16PM PST, ID: 21078669
For some reason I'm not getting the padding. I have a field Dollar_Amount there are 3 recs that have a dollar amount value. The amounts are 250, 200, 1125. i have a second field that is a sum of Dollar_Amount named Total_Amount. The values are displaying as 250, 200 and 1125, and the Total is displaying as 1575. I want them to display as 0000000000250, 0000000000200, 0000000001125 and 00000000000001575.
They are defined as:
Dollar_Amt  (decimal (13, 0), null)
Total_Amount  (decimal (17,0), null)

 
03.09.2008 at 12:47AM PST, ID: 21080693

Rank: Savant

can you show the full relevant code?
there must be something else...
 
03.10.2008 at 03:25AM PDT, ID: 21085138

DECLARE @Cnt int;
DECLARE @Amt int;

BEGIN                                                -- HDAJ ACSB 022208 082815      6 Byte date(mmddyy) 6 byte time (hhmss) 2 seperate fields
      INSERT INTO dbo.tbl_Output (Record_Code, Institution, hdrDate, hdrTime)
      Values ('HDAJ','ACSB', replace(CONVERT(CHAR(8), getdate(), 10), '-', ''),  
      replace(CONVERT(CHAR(8), GETDATE(), 108), ':', ''))

      INSERT INTO dbo.tbl_Output (Record_Code, AJ_Batch_Type, AJ_Batch_Code,
                  AJ_Batch_Num, AccountNumber, AJ_Tran_Code, Merchant_No, AJ_Dollar_Amt, Reason_Code, AJ_Merch_Descr, [Timestamp])
      SELECT AJ_Record_Code, AJ_Batch_Type, AJ_Batch_Code, AJ_Batch_Num,
                        AccountNumber, AJ_Tran_Code, Merchant_No,
                        Right('0000000000000' + Cast(AJ_Amount as varchar (13)), 13),
                        Reason_Code, AJ_Merch_Descr, [Timestamp]
      FROM dbo.tblArchive

      SET @Cnt = (SELECT Count(AJ_Record_Code) FROM dbo.tblArchive GROUP by AJ_Record_Code) + 2
      SET @Amt = (SELECT Sum(AJ_Amount) FROM dbo.tblArchive GROUP by AJ_Record_Code)
      INSERT INTO dbo.tbl_Output
                        (Record_Code,
                        Institution,
                        Record_Count,
                        Adj_Amount)
      SELECT 'TLAJ','ACSB', Right('00000' + Cast(@Cnt as varchar (5)), 5),
                  Right('00000000000000000' + Cast(@Amt as varchar (17)), 17)
END
END
 
03.10.2008 at 04:00AM PDT, ID: 21085273

Rank: Savant

just curious:

Right('0000000000000' + Cast(AJ_Amount as varchar (13)), 13),
vs
Right('00000000000000000' + Cast(@Amt as varchar (17)), 17)

is that really "correct", ie what you want?

also, what is the data type of the field Adj_Amount?
 
03.10.2008 at 04:09AM PDT, ID: 21085315
Angel1111 thanks for responding so quickly.
Adj_Amount int, it was nvarchar but I changed it when that didn't work. My values are 200,, 250, 1125 and 1575 (whch is the sum of the first three values)
I want 0000000000200; 0000000000250; 0000000001125
00000000000001575

The entire field s/b padded with zeros or numeric value.
 
03.10.2008 at 04:15AM PDT, ID: 21085338

Rank: Savant

>Adj_Amount int,
well, with data type int it won't store the leading 0 in the fields.
it would have to be varchar.
note: it would not really be a good practise though to store the leading 0's in the field...

suggestions:
* check up computed fields
* check out views
Accepted Solution
 
03.10.2008 at 05:03PM PDT, ID: 21091786
You are 100% correct I should know that from coding VB. I changed the field and now it works just fine. Thanks for everything Angellll
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628