Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: Monday, December 21, 2015 9:59 AM
Points: 11, Visits: 210
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: Thursday, June 2, 2016 7:55 AM
Points: 30, Visits: 274
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
Posted Tuesday, May 10, 2016 9:32 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 7,892, Visits: 765
Thanks for the script.
Post #1784826
Posted Tuesday, May 10, 2016 10:48 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 5:00 PM
Points: 23,168, Visits: 36,961
Iwas Bornready (5/10/2016)
Thanks for the script.


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



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1784853
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse