• I'm guessing here because your requirements aren't quite clear. What you seem to want to do is to set the Type column to either 'OK' or 'NOTOK', based on whether the Volume column is greater than zero or not. But what you are doing with the

    SELECT @Vol = Volume FROM @TestTable

    is getting the Volume of an arbitrary row in @TestTable, and then adding a new row to @TestTable, where you only insert a value for the Type column. What you really intend to do (if I am not mistaken) can be accomplished like this:

    UPDATE @TestTable

    SET Type =

    CASE

    WHEN Volume > 0 THEN 'OK'

    ELSE 'NOTOK'

    END

    This code hasn't been tested, but it should do what I understand it should do.

    BTW, it always helps adding a set of DDL statements that create test tables, plus a set of INSERT statements with test data, so that we (being volunteers) don't have to spend extra time creating those ourselves in order to help you out.

    Regards,

    Jan

    --------------------------------------------------------------------------
    A little knowledge is a dangerous thing (Alexander Pope)
    In order for us to help you as efficiently as possible, please read this before posting (courtesy of Jeff Moden)[/url]