Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple AFTER INSERT triggers on same table?

Status
Not open for further replies.

RRinTetons

IS-IT--Management
Jul 4, 2001
333
US
I have a vendor-supplied database that has a fairly extensive AFTER INSERT trigger on a particular table. I want to add my own trigger logic for the same table. My logic is independent of theirs. I believe that it should be OK to define a second trigger on the table, but I'm not certain. My understanding is that both triggers will run, but that the order in which they run for any given insert is not determined unless I do my own control. As I don't care in this case, I'll just skip that part of I don't have to worry about it.

1) Multiple AFTER INSERT triggers OK?

2) Is the INSERTED table valid and the same for both triggers?

3) Any reason I shouldn't send Database Mail from my trigger? In one very specific and (hopefully) rare instance?

-
Richard Ray
Jackson Hole Mountain Resort
 
1- Yes - multiple triggers work and you can easily set the order of the triggers if needd.

2- Inserted table is the same for all triggers. The caveat being, if a trigger inserts another row in the same table, the triggers will fire again.

3- I prefer not to send mail from triggers as this can hurt performance. Database mail seems to perform better than SQLMail. If you do send mail, minimize database queries from the mail procedure.

Terry L. Broadbent - DBA

"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top