September 9, 2010  
  Register Login 
BLOGS
There are no categories in this blog.

SEARCH BLOG

BLOG ARCHIVE
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Monthly
October, 2008
  SQL Server Blogs     



Your Ad Here

 
 
@@IDENTITY and SCOPE_IDENTITY() will return the last inserted identity value in the current session but in different scenarios they can each return different values.
While both @@IDENTITY and SCOPE_IDENTITY return the last identity value generated in any table in the current session, SCOPE_IDENTITY() will return the value only within the current scope (a scope is a stored procedure, trigger, function, or batch) while @@IDENTITY is not limited to a specific scope.
 
For example, nested stored procedures or triggers are part of the current session, but not part of the current scope. A scope is limited to the stored procedure or function that is explicitly invoked. This is how the @@IDENTITY and SCOPE_IDENTITY() can return different value when executing same stored procedure.
Permalink |  Trackback
Location: BlogsAleksandar Tosic's Blog    
Posted by: Aleksandar Tosic Wednesday, October 15, 2008

Your name:
Title:
Comment:
Add Comment   Cancel 
Copyright 2007 by www.dballinks.com Terms Of Use Privacy Statement