Getting Identity of an Updated Row

  • I want to return the identity for a row that was updated using an update statement.

    The update statement is as follows:

    UPDATE Answers

    SET InUse = @SessionID

    FROM (Select Top 1 AnswerID from Answers_Eligible) . . .

    I need the asnwerid for the updated record. @@Identity is only useful for inserts.

    Any suggestions appreciated.

    Thanks in advance

  • Could use "select top 1 identitycol from Answers_Eligible" after the update

    Paul Ibison

    Paul.Ibison@btinternet.com


    Paul Ibison
    Paul.Ibison@replicationanswers.com

  • select @somvar = Top 1 AnswerID from Answers_Eligible

    Then use this in hte update and return it.

    Steve Jones

    steve@dkranch.net

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

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