• basically this chunk of code

    SELECT @Vol = Volume FROM @TestTable

    IF @VOL > 0

    INSERT INTO @TestTable (Type)

    VALUES('OK')

    ELSE

    INSERT INTO @TestTable (Type)

    VALUES('NOTOK')

    will insert one row into @TestTable, which will have NULL in the Volume column (because you insert doesn't specify a value for that column) and either OK or NOTOK in the type column (depending on what the last record the select statement found in the table had in that column).

    If you change that code to something like

    UPDATE @TestTable

    Set Type '=CASE when @Vol > 0 THEN 'OK' ELSE 'NOTOK' END

    -- where 1 = 1 note that this line is commented out

    SO (1) specify which rows you want to change in the UPDATE statement (here it's all rows, which is the default, so you don't need a WHERE clause).

    AND (2) if you are trying to update rows you already inserted (as you are here) use UPDATE, not INSERT (which inserts new rows).

    Tom