Michael L John (2/15/2014)
You need three triggers (Ugh!); insert, update and delete.
Actually, you don't. Just calculate whether it's an INSERT, UPDATE, or DELETE and mark a column with I, U, or D. Remember that when a trigger fires, it won't contain mixed events. It will be because of an INSERT, UPDATE, or DELETE and never a mixture.
If I recall correctly, here's one of the faster ways to determine what the triggering action was.
IF NOT EXISTS (SELECT TOP 1 1 FROM DELETED)
SELECT @TriggerAction = 'I'
ELSE IF NOT EXISTS (SELECT TOP 1 1 FROM INSERTED)
SELECT @TriggerAction = 'D'
ELSE SELECT @TriggerAction = 'U'
;
--Jeff Moden
Change is inevitable... Change for the better is not.