Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger question
Message
 
 
To
22/01/2001 09:02:12
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00466553
Message ID:
00466569
Views:
9
>Hi,
>
>Is there any (quick easy) way to tell from within a trigger which event caused the trigger to fire? i.e. - if I have a trigger on update/insert - I would like to know whether it was an insert or an update that caused the trigger to hit
>
>TIA!

declare ninsert int, ndelete int
select ninsert = count(*) from inserted
select ndelete = count(*) from deleted

if ninsert > 0 /* insert trigger */
if ndelete > 0 /* delete trigger */
if ninsert > 0 and ndelete > 0 /* update trigger */

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform