Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scope_identity()
Message
 
 
À
09/10/2003 22:40:41
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00837243
Message ID:
00837250
Vues:
30
>We are looking at SCOPE_IDENTITY() to get the newly generated autoincrement. How does it work?

It's my understanding that SCOPE_IDENTITY() was created for just this scenario (new with SQL Server 7, if I recall correctly). After inserting a new row into the parent table, execute:

SELECT SCOPE_IDENTITY() as IDValue

on the server, and this will return a recordset with a single record containing the Identity value just created by the insertion. The problem with the earlier @@Identity was that it returned the last identity value generated, not necessarily the one on the current connection, which is what you're after.
>>-Steve->>

Steve Sawyer
Geeks and Gurus, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform