The resulting data type when you perform an operation on two decimal values is a complicated story, and I don't remember the rules by hart. But as you have experienced, dividing two decimal(10,2)
values does not result in a new decimal(10,2)
value.
I would write this as
cast( cast(B.Bweight as float)/cast(C.iWeight as float)*100 as decimal(10,2)) AS [Percentage]
The reason I would cast to float
before the division is that this the best accuracy for the division as such. But depending on the actual data types of the Weight columns, this may be an over kill. The important is that you need to cast the final result to decimal(10,2)
.