Groups | Blog | Home
all groups > sql server (microsoft) > may 2006 >

sql server (microsoft) : Triggers


John Franklin
5/3/2006 12:00:00 AM
If I update several rows of a table with a query, the update trigger on the
table only fires once, for the last row updated.

Is there any way to get it to fire as each row is updated? Alternatively,
can I detect which rows have been updated when the trigger fires?

John Franklin

John Franklin
5/3/2006 12:00:00 AM
Many thanks, Jens. I was forgetting that INSERTED/DELETED could hold
multiple rows.

John

[quoted text, click to view]

Jens
5/3/2006 3:04:00 AM
No thats wrong, a trigger is fired once per statement. Its up tp you to
handle the rows on your own. For example if you update mor ethan one
record at a time, the rows are present in the INSERTED (with the new
values) and the DELETED (with the old values) tables. So doing
something with the deleted rows (perhaps archieving or whatever would
lead to something like this:

INSERT INTO SomeArchiveTable
(
ColumnList
)
SELECT ColumnList
[quoted text, click to view]


HTH, Jens SUessmeyer.

---
http://www.sqlserver2005.de
---
AddThis Social Bookmark Button