Delete comment from: Javarevisited
You may be casting into too small an item.
E.G.
CAST ( (ITEMA *1.0 /ITEMB) AS VARCHAR(4) )
A case statement checks that the value is between 100 and 1000, and it was assumed (wrongly) that the value would fit into a four character container.
ITEMA and ITEMB are type INT.
The code errored (Arithmetic overflow) when trying to put numeric values like
nnn.0000000 into the 4 character container.
Jan 24, 2023, 1:30:14 PM
Posted to How to Fix Arithmetic overflow error converting numeric to data type numeric in SQL Server? Example