SQL Server – Best way to get identity of inserted row?

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?


Leave a Comment