Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dumb Question
Message
De
09/10/2002 15:30:11
 
 
À
09/10/2002 13:52:38
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Divers
Thread ID:
00709424
Message ID:
00709483
Vues:
22
There is nothing wrong with identity values. The issue with @@IDENTITY is that it returns the last identity value assigned for the connection, regardless of the table. Say that Table B has an identity column and Table A has an Insert trigger that inserts a row into Table B. When you insert a row into Table A, @@IDENITY will get the value from Table B not Table A.

If you're using SQL Server 2000, you can use the SCOPE_IDENTITY() function to get the correct identity value.

-Mike

>Hello Group,
>
>Hello Group,
>
>I have been thinking again, about primary keys.
>It is said not to use @@IDENTITY, I forget why.
>So, I would set up a table to store all my next values for all of my Primary Keys. If the next primary key is 256 for MyTable.MyNextpk and multiple users get the value 256 at the same time, each one incrementing the mynextPk value from 256 to 257 and inseting it back into mytable.myNextPk.
>Let say there were 10 simutaneous hits. MyNextPK would be 257 instead of 266. Or would it?
>
>Thanks
>Jim
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform