Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
>I am calling a stored procedure from VFP.
>
>sqlexec(nHandle, "{Call sp_GetNewKey}","nextid")
>thisform.txtInvoice.value = nextid.newid
>
>
>CREATE PROCEDURE sp_GetNewKey
>AS
>
>SELECT newid = @@identity
>GO
>
>
>How do I tell the stored procedure what table it is using? And to operate on insert?
>
>Thank you.
Are you using a sp to do the insert also?
In other words, you don't need two stored procedures to get to the id. After the parent insert you have access to its @@identity, and you can have the same sp execute the SELECT newid=@@identity as the last step to have it return the value.
I am assumming you have a parent-child situation where the insert on the parent happens first and then the children need the id for the foreign key.
Précédent
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