Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65

    Unanswered: Which trigger executes first?

    Hi!



    I have 2 DBs.

    DB1
    MID
    event
    date

    DB2
    MID
    event
    date
    tag (incremented by 1)

    DB1 contains a log of multiple events for each record while DB2 contains the latest log for the record. I have a trigger(trigger1) in DB1 that automatically updates/inserts the log in DB2 depending on whether the record already exists in DB2.

    I also have another trigger that checks for a specific value in the 'tag' field.

    I used to set this trigger(trigger2) up in DB2 but it was executed twice. The first one when trigger1 inserts/updates a DB2 record and the second one when trigger2 updates DB2. So instead of having only a value of 1 in tag, I get a 2.

    So what I did is I moved trigger2 to DB1. My only problem is I don't know which trigger get executed first.

    I'm not sure whether this is the best way of updating the 'tag' field. The purpose of the tag field is that when it reaches a certain number, it stops all events and inserts a termination log in DB2.

  2. #2
    Join Date
    May 2002
    Location
    General Deheza, Cba, Arg.
    Posts
    276
    you can set the order of your trigger with sp_settriggerorder, this sp are in the book online.
    Exist three order: first, none, last.

    Saludos
    Abel.

  3. #3
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65
    thanks! i'll check it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •