Comma is a character so SQL cannot return a numerical result with comma. However, SQL can convert a money column or value to a character data type and insert the commas.
Select '$'+convert(varchar(15),$100340.12,1)
Select '$'+convert(nvarchar(15),MoneyCol,1)
From tbl
Select '$'+convert(varchar(15),convert(money,@var),1)
Select '$'+convert(varchar(15),convert(money,12456),1)
Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
Select reverse(substring(reverse('$'+convert(varchar(15),MoneyCol,1)),4,11)) Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
But now an even better question - what if I want to use a SUM of the values and want it returned with a comma? It does not want to let me do any of the mathematical functions on it once I have converted to VARCHAR.
Put the SUM function inside all the other functions.
Select reverse(substring(reverse('$'+convert(varchar(15),Sum(MoneyCol),1)),4,11)) Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.