|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update Trigger - how to cacptures only changesHi,
I've created a trigger to capture 2 fields (f1 and f2). I did and check by using If update(f1) or update(f2) then only firing the trigger to create old and new image. But, this trigger will be fired eventhounght the f1 and f2 value did not change. How do I check the changes before fire the update trigger. Please advise. Ben Join the INSERTED and DELETED virtual tables in your trigger code and
compare the column values. Remember that a trigger fires once per update not once per row - there may be more than one row in those tables. -- David Portas SQL Server MVP -- Hi David,
Where can I find a documentation or sample code on this ? Thank you in advance. Benny Show quote "David Portas" wrote: > Join the INSERTED and DELETED virtual tables in your trigger code and > compare the column values. Remember that a trigger fires once per update not > once per row - there may be more than one row in those tables. > > -- > David Portas > SQL Server MVP > -- > > > Read introduction here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_08_0lo3.asp
A few samples are available under "CREATE TRIGGER". ML
Other interesting topics
|
|||||||||||||||||||||||