Inserting multiple rows - capture each identity value

  • Hello All,

    I have a SP which copies records from a table to the same table with new ItemID where old ItemID matches from the parameter passed. The code enters records in serveral tables.

    When multiple records are inserted from TableA to TableA for ItemID = 2 where ItemID = 1, (table A has Identity column) I need to capture each identity values in a varible = @@Identity. Currently it just stores the last @@identity.

    How should I get every identity values since I have to enter recods in another table for each identity value.

    Thanks,

  • Look at the OUTPUT clause for INSERT statements in BOL

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

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

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