Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger question
Message
 
 
À
22/01/2001 09:02:12
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00466553
Message ID:
00466569
Vues:
10
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform