Multiple insert trigger

If you are inserting/updating multiple rows in a database and you need to do some processing on the inserted data you may need to add a bit of recursion to your trigger code to handle each record corretly.

The example below uses a while loop to run through each inserted row and updates some relational data in the updated table.

As an addendum… In general, avoid triggers unless you absolutely have to use them


One thought on “Multiple insert trigger

  1. The newid() pelborm IS a real pelborm for o/r mappers: there’s no way to obtain the new value. The main thing is the default value for a field which is newid()’. There’s no way to detect that at runtime. With identity fields, one could simply obtain the latest value and that’s inserted.though in 2005 they introduced NEWSEQUENTIALID(), which IS retrievable with a piece of sql. llblgen pro supports this so auto-guid generation is supported through NEWSEQUENTIALID(). What’s odd is that they didn’t support this in EF. Oh well

Leave a Reply

Your email address will not be published.