Mahmoud ElMansy: knowledge meant to be free

T-SQL Convert INT to Comma-Separated Nvarchar

T-SQL Convert INT to Comma-Separated Nvarchar

SQL expression to change an Int like 123456789 to a comma-separated Nvarchar like ‘123,456,789.00’.

DECLARE @MyNum INT =123456789
SELECT CONVERT(Nvarchar, CONVERT(MONEY, @MyNum), 0)
--result: 123456789.00
SELECT CONVERT(Nvarchar, CONVERT(MONEY, @MyNum), 1)
--result: 123,456,789.00
SELECT CONVERT(Nvarchar, CONVERT(MONEY, @MyNum), 2)
--result: 123456789.0000