Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Find List of Columns Updated inside Trigger Expand / Collapse
Author
Message
Posted Wednesday, June 27, 2012 1:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 13, 2014 7:21 PM
Points: 4, Visits: 43
Comments posted to this topic are about the item Find List of Columns Updated inside Trigger
Post #1321720
Posted Monday, February 10, 2014 7:54 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, March 18, 2014 12:29 PM
Points: 10, Visits: 173
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.
Post #1539773
Posted Monday, February 10, 2014 12:39 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 2:43 PM
Points: 25, Visits: 171
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)

Post #1539914
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse