In SQL Server 2012 and higher, this will format a number with commas:
You can also change
Demo 1
Demonstrates adding commas:
Result
Demo 2
Demonstrates commas and decimal points. Observe that it rounds the last digit if necessary.
SELECT FORMAT(5000000.759145678, '#,##0.00')
Result
Compatibility
SELECT FORMAT([Number], 'N0')
You can also change
0
to the number of decimal places you want.Demo 1
Demonstrates adding commas:
Result
5,000,000
Demo 2
Demonstrates commas and decimal points. Observe that it rounds the last digit if necessary.
SELECT FORMAT(5000000.759145678, '#,##0.00')
Result
5,000,000.76
Compatibility
SQL Server 2012+
Komentar
Posting Komentar