I've started a new job and it involves looking at a bunch of big numbers. Is there an easy way to add commas to an int or decimal field to make it readable?

For example, SQL Server outputs the column on the left, but for my own sanity, I need it to look like the one on the right:

2036150 -> 2,036,150  

...or would I have to write some heinous

left(right(vandalized_data),6),3) + ',' + right(left(vandalized_data),6),3)


The perfect thing would be commas in the display grid, then plain integers in the output.


2 Answers 2


If you're on SQL Server 2012+, and you want to do it (without decimal places):

SELECT x = FORMAT(2036150, N'N0')

If you're on an earlier version, you have to jump through some hoops:

SELECT x = REPLACE(CONVERT(nvarchar(30), CONVERT(money, 2036150), 1), N'.00', N'');

TSQL's FORMAT function can do that. EG

select format(1232131312342132123.2222,'0,###.##')



If you want to use a different separator, you still use , which has a special meaning in .Net format string, and then replace the , with something else. EG:

select replace(format(123445678.2222,'#,###.##'),',','_')



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.