Link to home
Start Free TrialLog in
Avatar of jobprojn
jobprojnFlag for United States of America

asked on

T-SQL - Concatenate Memo and Currency

Hello.  I have two fields, one memo and the other currency.  I need to concat both fields into a single field but I need the currency format for the PurchaseOrder.Amount to stay intact with comma separators.  My current code is shown below.  Problem here is the PurchaseOrder.Amount field looses all commas (i.e. $23335561.23)

Anybody have a relatively simple solution?

[NewMemo] = CAST(PurchaseOrder.Memo AS Nvarchar(2000))
                       + ' $'
                       + CAST((PurchaseOrder.Amount + tax1 + tax2 + tax3) AS nvarchar(20))
ASKER CERTIFIED SOLUTION
Avatar of Shannon_Lowder
Shannon_Lowder
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If your field is already a money type, you don't need to cast to money.

[NewMemo] = CAST(PurchaseOrder.Memo AS Nvarchar(2000))
                       + ' $'
                       + CONVERT(nvarchar(20), convert(money, PurchaseOrder.Amount + tax1 + tax2 + tax3), 1)
Just seconds late...
I see Shannon has already given you the answer.  Convert allows you to specify the style, check BOL.
Avatar of jobprojn

ASKER

Beautiful.  Thanks.