How To Format A Number With Commas

Facebooktwitterredditpinterestlinkedinmail

SQL Server 2012 makes it a lot easier to format a number with commas, but let’s face it… previous versions haven’t been so nice to us. ¬†Here are the easiest ways that I know to format a number with commas.

SQL Server 2012+

SELECT	FORMAT(1234567890, '###,###,###') AS 'FormattedNumber'

SQL Server 2008 And Previous

SELECT	REPLACE(CONVERT(VARCHAR(50), (CAST(1234567890 AS money)), 1), '.00', '') AS FormattedNumber