|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Triggers and bach insertI'm using an INSERT INTO...SELECT * FROM bulk statement to insert records
into a table. If I write a trigger on the target table that executes on INSERT, will the trigger fire for each row inserted? If not, how can I get the trigger to fire for each row? Thanks in advance >>will the trigger fire for each row inserted? No, triggers fire per statementuse the inserted and deleted pseudo-tables to do what you need to do Denis the SQL Menace http://sqlservercode.blogspot.com/ First of all, please note that INSERT INTO from a SELECT is not a "bulk"
operation ("bulk" has a special meaning, so it's important to differentiate). Triggers in SQL Server fire once per operation -- in this case, once for the INSERT itself. Within the scope of a trigger you can access the "inserted" and "deleted" virtual tables, which will allow you to programatically act on the rows that were affected by the operation. The "inserted" table contains all of the rows that were inserted -- so you should be able to do whatever it is you need to do by acting on that table. -- Show quoteAdam Machanic Pro SQL Server 2005, available now http://www.apress.com/book/bookDisplay.html?bID=457 -- "bill" <b***@no.com> wrote in message news:OSeP382eGHA.3792@TK2MSFTNGP03.phx.gbl... > I'm using an INSERT INTO...SELECT * FROM bulk statement to insert records > into a table. If I write a trigger on the target table that executes on > INSERT, will the trigger fire for each row inserted? If not, how can I get > the trigger to fire for each row? > > Thanks in advance > > |
|||||||||||||||||||||||