return column value (such as ID) as part of insert statement

  • Dear All

    How can I get the Id (this is an identity type column) of an inserted record as part of the insert statement?  In Oracle, we used to use the "return Column_name" parameter at the end of the insert statement.

    Thank you

  • Depending on which version of SQL and if wrapped in an SP or submitted together properly you can use

     

    @@IDENTITY, SCOPE_IDENTITY, and IDENT_CURRENT

     

    With 2000 it is better to use SCOPE_IDENTITY.

     

    See BOL for more info.

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

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