Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    6

    Unanswered: how to implement a Multirow insert trigger?

    I have the following trigger:
    Create trigger [dbo].[new_Location]
    on [dbo].[TBL_LOCATIONS]
    for insert
    as
    insert into dbo.tbl_Events ( Event_Id , Location_Id )
    SELECT NewID(), Inserted.Location_Id
    FROM Inserted

    Which works fine on single-record inserts, however, on multiple row inserts to tbl_Events (batch load) the trigger doesn't fire. How can I modify it to work for multiple record inserts?

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Are you using BCP?
    I don't think BCP fires triggers.
    Also possible that some command in your batch process is temporarily disabling the trigger.
    Either way, there is nothing wrong with your trigger. It should fire on any insert.
    If it's not practically useful, then it's practically useless.

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

  3. #3
    Join Date
    Nov 2003
    Posts
    167
    If your insert into tbl_locations uses a bulk copy operation (bulk copy, bcp, etc), you'll need to specify the hint FIRE_TRIGGERS.

    Using bcp and BULK INSERT
    Kit Lemmonds

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Bingo. Thanks for the link Mr. Salad.
    If it's not practically useful, then it's practically useless.

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

Posting Permissions

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