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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 what is the diffrence between @@identity ,scopiden

Author  Topic 

boreddy
Posting Yak Master

172 Posts

Posted - 2008-08-19 : 04:13:38
what is the diffrence between @@identity ,scopidentity

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-19 : 04:23:58
@@identity gives last generated id value (but not necessarily in same scope) while scope_identity always gives the identity generated in same scope.
the difference can be noted in case where you've a insert trigger enabled on your table which logs action onto a audit table. @@identity will return the id generated for audit table which is actually done by trigger whilst scope_identity gives id generated inside main table.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-19 : 04:25:23
more explanation below:-
http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/
Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-08-19 : 06:17:13


check this blog for more information.

http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-19 : 06:19:31
quote:
Originally posted by VGuyz



check this blog for more information.

http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/


why are you reposting the link which i posted 2 hrs ago?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-19 : 06:36:44
maybe it's a kind of parrot-syndrom

Planning replaces chance by mistake
Go to Top of Page
   

- Advertisement -