Text: Arithmetic overflow error converting varchar to data type numeric

I dont even know where to begin, like here you are casting to a varchar and then trying to do >= against a numeric.

Also in your else you are returning 0 (a int).

For starters I would probably not cast in the areas where you are comparing it against =, <> or >= or <= or > or <

cast(SubQuery1.OrderDtl_IUM as varchar(10)) = 'GRS'

This one should be ok, but you dont need a cast. Depending on your SubQuery if its a Left Join you might need to use ISNULL().

1 Like