Aleksandar's computer workshop

Let's see what Aleksandar was fixing today.
My findings, tips & tricks related to computers, internet, programming and other stuff I was working with.

Properly Capturing Identity Values

When inserting a row into a database table that contains an identity column, I need a way to capture the identity value generated by the database engine after it inserts the row into this table. What can I use to capture this value while also making sure this value is accurate?

SQL Server provides three different functions for capturing the last generated identity value on a table that contains an identity column:
1) @@IDENTITY
2) SCOPE_IDENTITY()
3) IDENT_CURRENT(‘tablename’)

But which should you use? Check out this article for more information:
http://www.mssqltips.com/tip.asp?tip=1385