Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning Identity after Insert
Message
De
16/09/2005 16:17:15
 
 
À
16/09/2005 13:26:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
ASP.NET
Database:
MS SQL Server
Divers
Thread ID:
01050383
Message ID:
01050490
Vues:
18
>>PS: Warning if inserting via a stored procedure than SCOPE_IDENTITY wouldn't work. However you could query directly:<

I just wanted to comment on this Cetin. SCOPE_IDENTITY with a Stored Proc works just fine. You'd set an OUTPUT parameter to the SCOPE_IDENTITY value.

~~Bonnie




>>I have an application in Asp.Net that writes to a SQL Server table. This SQL Server table has an Identity column.
>>
>>How can I return the value of the Identity column after performing an Insert into the table?
>>
>>Thanks,
>>
>>Jerry
>
>Jerry,
>You would request SCOPE_IDENTITY back. Instead I suggest you to use GUID as unique IDs. You don't need to request back then because you know them before inserting.
>PS: Warning if inserting via a stored procedure than SCOPE_IDENTITY wouldn't work. However you could query directly:
>select IDENTCOLUMN from inserted
>Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform