Tiggers and @@Identity

  • I have a proc that inserts into a table. I grab the @@Identity of the new ID after the insert. I also have an After Insert Trigger on this table.

    When this trigger runs it inserts into another table that creates an ID.

    The problem is the @@Identity that I'm attempting to get from the intial table is the ID from the table the trigger inserts into.

    I'm not quite sure how to handle this... how can I get just the ID from the intial table?

  • Use scope_identity() instead of @@identity

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks GSquared. I had dug around a little but you know how that goes... it can easily turn into hours!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply