• All your variables are defined as INT which means you are getting all INT values . This:

    (ISNULL(@vperc,0)/100)

    will return a 0 for any @vperc values that are below 100 because the conversion to INT is doing truncation. And anything multiplied by 0 equals 0. One way to fix it is to make @vperc a float/decimal/numeric type with a precision > 0 or you can change all the places you have "/100" to "/100.00"

    For verification run this:

    DECLARE @vperc INT, @vperc2 DECIMAL(10, 2)

    SET @vperc = 99

    SET @vperc2 = 99

    SELECT

    @vperc/100 AS int_values,

    @vperc/100.0 AS one_hundred_with_decimal,

    @vperc2/100 AS variable_as_decimal

    I'd also suggest you look into a way to do this without a cursor. As the cursor is killing your performance and causing your transaction to be longer than necessary. I don't have time right now to propose a set-based solution, but if I have some time later I'll give it a shot.