Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Scope_Identity vs @@identity
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

12 Posts

Posted - 06/19/2010 :  22:10:51  Show Profile  Reply with Quote

In which scenario does @@identity will fail.Pls explain in detail.Diff bet Scope_Identity vs @@identity



Almighty SQL Goddess

38200 Posts

Posted - 06/20/2010 :  00:05:58  Show Profile  Visit tkizer's Homepage  Reply with Quote
@@IDENTITY could be wrong if you have a trigger on the table. If you want it explained in detail, then I'd suggest searching this site for the many articles and threads that discuss this topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server

Subscribe to my blog
Go to Top of Page

Starting Member

9 Posts

Posted - 06/20/2010 :  22:57:11  Show Profile  Reply with Quote
spam removed
Go to Top of Page

Norsk Yak Master

3271 Posts

Posted - 06/21/2010 :  02:32:53  Show Profile  Reply with Quote
@@identity is global. When you ask for @@identity you might get an identity value that was inserted in another statement/stored procedure while scope_identity always gives you the last identity in the current scope. Therefore you shuld always use scope_identity...

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000