Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    10

    Unanswered: for insert trigger

    how do i stop an insert action to take place in an after insert trigger (when let's say i inserted more than one record at a time)?
    thank you

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Huh? What's wrong with inserting more than one record at a time?
    The solution is to write your triggers to handle multi-record transactions, not to make them force rollbacks.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    Agree with Blindman. If you have a broken trigger you should fix it. If you have trigger code that isn't applicable to every single insert then it shouldn't go in a trigger.

    It's amazing how many triggers I see with all sorts of complex logic that really should never be inflicted on every user, developer or DBA who wants to insert a row. The best place to put any code that modifies data in any way is to put it in a stored procedure, not in a trigger.

    You can selectively disable a trigger using ALTER TABLE... DISABLE TRIGGER.
    ALTER TABLE (Transact-SQL)

    Ufortunately that ALTER command is scoped to the table, not just your transaction, so all users in the database will be affected. This is why you should think very, very carefully before you put any code at all into a trigger.

Posting Permissions

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