Wednesday, March 28, 2012

How do I know what action triggered a trigger...

Hello

If I have a trigger for INSERT and DELETE, how do I know what action was executed ??
I prefer not to split the trigger to one for each action, because the the procedure for both is almost the same.

Another question, How can I know what records were updated? I need to concatenate the ID/ID's to the SQL in the procedure.

Thanks,

Inon.If (EXISTS(SELECT * FROM INSERTED))
Trigger for INSERT
If (EXISTS(SELECT * FROM DELETED))
Trigger for DELETE

go thru BOL for more information about INSERTED,DELETED tables|||If (EXISTS(SELECT * FROM INSERTED))
Trigger for INSERT
If (EXISTS(SELECT * FROM DELETED))
Trigger for DELETE

go thru BOL for more information about INSERTED,DELETED tables

Ok Thanks,
But tell me, isn't it a bit spendy on resources ?

Inon.

No comments:

Post a Comment