Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL commands not executing
Message
De
12/02/2009 18:51:43
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Application:
Desktop
Divers
Thread ID:
01381043
Message ID:
01381458
Vues:
34
I disagree. I think it depends on how you make your updates and if there are any triggers or child tables and what identity you are trying to verify. SCOPE_IDENTITY() is limited to values inserted only within the current scope while @@IDENTITY is not. It is limited by session only. I guess he could use IDENT_CURRENT if he wanted to limit it to a specific table and he didn't care which connection added the record. I know most recommend SCOPE_IDENTITY() in case triggers are added later, but it really depends. This discussion is moot anyway since he doesn't have any identity columns. :o)

I posted a link for him, but I also like this description:

http://www.dotnetjunkies.ddj.com/Article/86F0988E-FED4-414F-BA2E-D01D953C11BE.dcik

and this:

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





>>If I remember correctly, @@IDENTITY doesn't apply to GUIDs, right? I am using uniqueidentifiers....
>>
>
>No, it doesn't apply. You can create new GUID with NewID()
>
>Also it's much better and safer to use SCOPE_IDENTITY() to get the newly created ID.
>
>>>We have an identity column on every table and use @@IDENTITY to check inserts:
>>>
>>>http://www.kamath.com/tutorials/tut007_identity.asp
>>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform