September 13, 2005 at 3:55 am
Greetings
I have a trigger that does some calculations on the row every time a row is inserted or edited.
For inserts i use scope_identity() to identify the inserted row. I am not sure how to get the identity of the just edited row.
Can anyone propose a method of better identifying the identity of the just inserted or edited row?
Regards
September 13, 2005 at 5:18 am
Check out the inserted and deleted tables in BOL... I think that should give you the answer you're looking for. (Look up "inserted tables" in the index.)
September 13, 2005 at 8:04 am
Dimitri - as Paul indicates, you could check one of several things depending on your requirements....
1) you could select @@rowcount to find out how many rows have been affected by the update.
2) you could check against a specific column by using UPDATE(colName)
3) you could select from the Deleted table to see which rows are being modified.
**ASCII stupid question, get a stupid ANSI !!!**
September 24, 2005 at 6:11 am
use inserted.ID or deleted.ID in the "inserted" or "deleted" table, i.e. the inserted/deleted row
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply