How to distinguish operation type in trigger?
- From: Hubert Trzewik <hubert.trzewik@xxxxxxxxx>
- Date: 31 May 2007 03:19:11 -0700
Hi,
I want to have all-in-one trigger, defined like this:
CREATE TRIGGER MyInsertDeleteUpdateHandler
ON MyTable
FOR DELETE, INSERT, UPDATE
AS
BEGIN
(...)
END
Now, how can I tell why this trigger was fired (what event caused
trigger to be fired) - was it DELETE, INSERT or UPDATE?
Is there something like this: @@event_type,
so I could do for example IF (@@event_type = DELETE) (...)
Of course I can create 3 triggers instead of 1, to be sure what event
fired my trigger.
I can also count records in _deleted_, _inserted_ tables or to do
JOINs with it. But, _inserted_ table is common for UPDATE and INSERT
events..
Any suggestions?
Thanks in advance.
Hubert
.
- Follow-Ups:
- Re: How to distinguish operation type in trigger?
- From: M A Srinivas
- Re: How to distinguish operation type in trigger?
- From: Dan Guzman
- Re: How to distinguish operation type in trigger?
- Prev by Date: Re: needed: 1 + null = 1 (Correction)
- Next by Date: Re: needed: 1 + null = 1 (Correction)
- Previous by thread: Re: DOWNLOAD CRACKED 2007's SOFTWARE: ARCHICAD 11,UNIGRAPHICS NX5,SOLIDWORKS 2008,XSTEEL 13,AUTOCAD 2008
- Next by thread: Re: How to distinguish operation type in trigger?
- Index(es):