Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL commands not executing
Message
 
 
À
13/02/2009 09:21:26
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:
01382663
Vues:
58
Tracy,

Just in case I missed something please also check http://forums.asp.net/p/1386597/2949899.aspx#2949899 the last answer from the SQL Server expert.

>I think you missed something then because it is not always SCOPE_IDENTITY() is better. It depends.
>
>
>>Hi Tracy,
>>
>>Not sure what did you want to prove with these two links, since both recommend SCOPE_IDENTITY() :)
>>
>>>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
>>>>>>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform