Information générale
Titre:
SQL Server @@Identity
Perhaps this is not the best place to post a SQL Server question, but here goes anyway...
In VFP, I commonly insert parent and child rows into tables by first generating a primary key value for the parent table and then using that as the foreign key value for the child rows. This way, of course, the child rows are properly related to the parent.
How is this done in SQL Server? That is, how do I generate the "Next ID" for the parent so that I can use that value when inserting the child records? I suppose the T-SQL @@Identity could be used, but isn't that scoped to the connection and therefore not guaranteed to be the unique when I actually insert the parent record?
TIA,
Alan
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement