Say I have a TSQL trigger
CREATE TRIGGER dbo.Trigger1 ON dbo.Table1
AFTER INSERT, UPDATE, DELETE
How do I know which one of the above operations (insert, update, or delete) caused the trigger to fire?
Say I have a TSQL trigger
CREATE TRIGGER dbo.Trigger1 ON dbo.Table1
AFTER INSERT, UPDATE, DELETE
How do I know which one of the above operations (insert, update, or delete) caused the trigger to fire?
You could check for the existence of the inserted
and deleted
tables.
If only values in inserted
exist, it was an insert. If only values in deleted
exist, it was a delete. If both, it was an update.