Get SUM of VARCHAR values in SQL Server

Last Reply 29 days ago By dharmendr

Posted 29 days ago

Hi!

I want get sum of to varchar number. 

declare @sum char(9) = '33,87', @sm char(9) = '55,83'
select REPLACE((Convert(MONEY, @sum) + Convert(MONEY, @sm )),',','.')

Result: 89.7

You are viewing reply posted by: dharmendr 29 days ago.
Posted 29 days ago

Hi PRA,

Refer below query.

SQL

DECLARE @sum CHAR(9) = '33,87', @sm CHAR(9) = '55,83'
SELECT CONVERT(MONEY,REPLACE(@sum,',','.')) + CONVERT(MONEY,REPLACE(@sm,',','.'))

Output

89.70