What operation type invoked a trigger in SQL Server 2008?
- by Neil Moss
I'm contemplating a single SQL trigger to handle INSERT, UPDATE and DELETE operations as part of an auditing process.
Is there any statement, function or @@ variable I can interrogate to find out which operation type launched the trigger?
I've seen the following pattern:
declare @type char(1)
if exists (select * from inserted)
if exists (select * from deleted)
select @Type = 'U'
else
select @Type = 'I'
else
select @Type = 'D'
but is there anything else a little more direct or explicit?
Thanks,
Neil.