Don’t use @@Identity

Don’t use @@Identity to select the ID of the newly inserted record, use scope_identity() instead.

@@Identity returns the most recently created identity for your current connection. When you first use it, it might be fine, but if someone adds a trigger that causes another identity to be created, that one will be the one which is returned.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.