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!
SQL Fiddle Demo You can first replace thousand separator comma(,) to a Zero length string (''), and then you can replace Decimal('. ') to comma(',') in the same select statement.
In order to fetch the comma separated (delimited) values from the Stored Procedure, you need to make use of a variable with data type and size same as the Output parameter and pass it as Output parameter using OUTPUT keyword.
You can use backslash(\) to insert commas into values.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With