Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tigerweld
Starting Member
12 Posts |
Posted - 2011-05-26 : 12:00:14
|
| I'm trying to run a query that has a currency field. I prefer to have it formatted as a flat fixed width field. Currently it comes out like 232.525166.5On vaules that don't have anything to the right of the decimal it leaves the decimal off. I need to format like the following:000002325000000025000000016650Can someone show me how to do this? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-05-26 : 12:14:41
|
| This should be done in the front-end app, butselect RIGHT('0000000000'+ convert(varchar(10),convert(int,CurrencyField*100)),10)JimEveryday I learn something that somebody else already knew |
 |
|
|
tigerweld
Starting Member
12 Posts |
Posted - 2011-05-26 : 12:27:12
|
| Not sure I follow you. Here is my query.SELECT Client_db.dbo.Deposits.DDA, Client_db.dbo.Deposits.SiteID, Client_db.dbo.Deposits.TimeTransmitted, Client_db.dbo.MICR.CheckNumber, Client_db.dbo.MICR.Amount FROM Client_db.dbo.DepositsINNER JOIN Client_db.dbo.MICRON Client_db.dbo.MICR.DepositID = Client_db.dbo.Deposits.DepositIDWHERE Client_db.dbo.Deposits.CustomerID = '132'The 'Amount' field is the one in question. |
 |
|
|
tigerweld
Starting Member
12 Posts |
Posted - 2011-05-26 : 12:30:02
|
| Nevermind, I got it. I replaced CurrencyField with my field name, sorry! |
 |
|
|
tigerweld
Starting Member
12 Posts |
Posted - 2011-05-26 : 12:32:06
|
| I have one more format question regarding the TimeTransmitted field. Do I post it here or start a new thread for others? |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-05-26 : 13:03:20
|
| Start a new thread.JimEveryday I learn something that somebody else already knew |
 |
|
|
tigerweld
Starting Member
12 Posts |
Posted - 2011-05-26 : 14:20:22
|
| Thanks Jim! I GREATLY appreciate it! |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-05-29 : 18:56:28
|
| >> I'm trying to run a query that has a currency field. <<Columns are not fields; currency is not a data type. That was COBOL in the 1950's. >> I prefer to have it formatted as a flat fixed width field [sic]. <<Good SQL programmers do the display formatting in the front end, never in the database. That was also COBOL. All you got was kludges to make you a worse programmer. Sorry. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|
|
|