Reputation: 2433
I'm using SQL Server 2008
I have just a decimal value as 137909.19
and I need to convert it to varchar
with this format: 137,909.19
.
declare @myNumber decimal(15,2) = 137909.19
select CAST(@myNumber AS varchar(20)) -- Result: 137909.19
I have looked over several posts but I can't found the solution.
How could I achieve this?
Upvotes: 1
Views: 11227
Reputation: 106
Try casting it as money.
declare @myNumber decimal(15,2) = 137909.19
declare @myvalue varchar(20)
set @myvalue = convert(varchar, cast(@myNumber as money),1)
PRINT @myvalue
output will be "137,909.19"
Upvotes: 7