0

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?

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
Mark Williams
  • 583
  • 7
  • 18

1 Answers1

2

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.

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
Jeff Rosenberg
  • 3,522
  • 1
  • 18
  • 38