Find List of Columns Updated inside Trigger

  • Comments posted to this topic are about the item Find List of Columns Updated inside Trigger

  • The only thing I don't like about this at first glance is there is no check to see if the data actually changed. So if I issue the statement...

    UPDATE Users

    SET user_name = user_name

    WHERE user_id = 'Fred1234';

    ...then the code fragment supplied will say the column was updated, when in fact nothing changed.



    I am Melvis.

  • I agree Matt. This is what I use in my triggers to see if a change has actually occurred.

    IF EXISTS (SELECT *

    FROM

    INSERTED I JOIN DELETED D ON I.Key = D.Key

    WHERE

    I.Col <> D.Col)

  • Thanks for the script.

  • Iwas Bornready (5/10/2016)


    Thanks for the script.

    What script? Looks to me like you are just trying to increase your post count.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply