From within the trigger code - how can I tell whether the trigger has been fired from an insert, update, or delete?
The only thing I can think of is to check the Inserted and Deleted and use logic on these... for example in pseudocode:
IF COUNT(*) FROM Inserted IS NULL THEN Action = 'delete'
ELSE IF COUNT(*) FROM Deleted IS NULL THEN Action = 'insert'
ELSE Action = 'update'
Is there a better way?
The only thing I can think of is to check the Inserted and Deleted and use logic on these... for example in pseudocode:
IF COUNT(*) FROM Inserted IS NULL THEN Action = 'delete'
ELSE IF COUNT(*) FROM Deleted IS NULL THEN Action = 'insert'
ELSE Action = 'update'
Is there a better way?