• Hugo Kornelis (9/5/2008)


    That's why many developers make it a habit to start each trigger with this line:

    IF @@ROWCOUNT = 0 RETURN;

    Do make sure that it's the very first line of the trigger, though.

    DO NOT use this in a trigger to test if any rows need to be processed by the trigger.

    Although this technique has been documented in independent books (e.g., Ken Henderson) the value could be zero from some other action performed by some other trigger. I.e., the value of @@ROWCOUNT does not always reflect the number of rows affected in the table that the trigger is attached to.

    From BOL:

    Returns the number of rows affected by the last statement.

    Trust me on this as I have had this experience!


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]