SQL Server - Best way to get identity of inserted row?
Asked 07 September, 2021
Viewed 3.1K times
  • 60
Votes

What is the best way to get IDENTITY of inserted row?

I know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDENTITY but don't understand the pros and cons attached to each.

Can someone please explain the differences and when I should be using each?

14 Answer