I have the following query which is throwing:
Arithmetic overflow error converting varchar to data type numeric.
Query:
Select
@Fee = Case
When IsNull(Fee, '') = '' Then 0.00
Else Fee
End
@Fee is of type Money, and Fee is Varchar type.
I have also observer that for following types of data in Then clause no error is being displayed.
Select @Fee = Case When IsNull(Fee, '') = '' Then 1 Else Fee End
Select @Fee = Case When IsNull(Fee, '') = '' Then 1.0 Else Fee End
So only for values 0.00 or 0.0 in Then clause I am getting error.
I have also tested with below query and worked fine:
Select @Fee = Case When IsNull(Fee, '') = '' Then Cast(0.00 as money) Else Fee End
And more interesting thing is that, as per data we have in table, Then part of the Case statement will never be executed. Please help me understanding this behavior of Case statement.