Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to generate PK on SQL table
Message
 
À
05/01/2001 10:03:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00459598
Message ID:
00459890
Vues:
30
Sure. You need to make sure you save the @@identity value before you do anything else. FWIW, I don't see why one would use triggers for this sort of thing anyway...

< JVP >


>But if the table where the record is being inserted by the stored procedure has an insert trigger that inserts records into other tables, and those tables have identity fields, won't @@identity return the identity value of the last table that had inserted records?
>
>>>>
>>I understand there are potential problems using Identity fields in SQL to generate a PK.
>>
>>1. Trying to return value with @@identity may give value for insert on another table
>><<
>>
>>Not if you use a stored procedure to add records. After the insert, assign the value of @@Identity to an output variable. Or, just return @@Identity.
>>
>>
>>< JVP >
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform