Saturday, 17 February 2018

MSSQL - Fix Error - Operand data type varchar is invalid for sum operator.


Watch this example on YouTube


To fix it replace

Declare @Amount As Varchar(10) = '200'
Select Sum(@Amount) as Amount

with

 Declare @Amount As Varchar(10) = '200'
Select Sum(Cast(@Amount As Money)) as Amount

No comments:

Post a Comment