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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help to add money value

Author  Topic 

wallywizard
Starting Member

2 Posts

Posted - 2014-08-06 : 14:10:59
I am trying to add a field (bank_chk_amt] from a table in to my query to bring in a dollar amount....I originally had this below

SELECT dbo.CBPAYMENT.REFERENCE_NO, 'CCMCCHBREF' AS Literal, RTrim([description]) + ', ' + [bank_chk_amt] + ', ' + convert(char(10),[check_date],101) + ', ' + 'Refund check sent to ' + [payee_name] AS [Free Text]
FROM dbo.CBPAYMENT;

but I would get "Error converting data type varchar to numeric".

So my co-worker modified it and added (str([bank_chk_amt]) to my query which worked, but I noticed it dropped of the cents. So instead of 80.35 it would show 80 And I noticed it rounded 100.50 to 101


How can I bring in the full dollar amount and without adding?

wallywizard
Starting Member

2 Posts

Posted - 2014-08-06 : 14:13:49
edit------------

I meant to say at the end, how can I bring in the full dollar amount and without rounding?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-08-06 : 14:32:08
Return raw data from SQL. If you need to form a string based on the columns returned, do that in your application. Presentation issues should be handled in the application layer, not in SQL.

SELECT REFERENCE_NO, 'CCMCCHBREF' AS Literal, RTrim([description]), bank_chk_amt, check_date, payee_name AS [Free Text]
FROM dbo.CBPAYMENT;

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -