• kd11 (5/4/2015)


    Let me re-word that, I want to fire a trigger when column2, column3, column5 and column9 are updated/insert (not the other six columns) so do I need to use the "column_update" statement.

    column_update is very misleading, since it just checks if the column name was included in the DML command, and not whether the values actually changed.

    you might need to handle NULLS as well, so this is just to provide an example:

    the best way is to check by comparign the INSERTED virtual table to teh DELETED virtual table, on a column basis.

    ie

    IF EXISTS(SELECT * FROM INSERTED i INNER JOIN DELETED d ON i.PKColumn = d.PKColumn WHERE i.Name <> d.Name OR i.Address1 <> d.Address1)

    BEGIN

    --log some extra data? send an email? do something

    END

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!