I have a column called TotalArea
and its format is numeric (12,2)
.
I want it to display the numbers with a thousand separator so when I
select TotalArea from table
to show me a format like 1,234.00
.
How could I do that? Thanks!
I have a column called TotalArea
and its format is numeric (12,2)
.
I want it to display the numbers with a thousand separator so when I
select TotalArea from table
to show me a format like 1,234.00
.
How could I do that? Thanks!
Try this way:
select replace(convert(varchar,convert(Money, TotalArea),1),'.00','')
from table
or
SELECT CAST(CONVERT(varchar, CAST(123456 AS Money), 1) AS varchar)
from table
SELECT FORMAT(12345,'#,0.00');
SELECT FORMAT(TotalArea,'#,0.00') from table;
Reference: https://msdn.microsoft.com/en-us/library/ee634206(v=sql.105).aspx
Formatting numbers for display is something that should be done in the display layer, and not within the database. So, in whatever application this data ends up being used, you should format it there. Management Studio, unfortunately, does not offer much control in this regard.
use this simple.... format(CHART_OF_ITEM.UNIT_PRIC_W_TAX, '#,0.00') AS UNIT_PRICE_W_TAX
Try this One awesome example.
SELECT CAST(CONVERT(varchar, CAST(123456 AS money), 1) AS varchar)