Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Store mutiple identity values from insert
Message
De
16/07/2002 09:38:09
 
 
À
02/07/2002 16:52:23
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00674695
Message ID:
00679073
Vues:
17
Would the inserted table in the trigger have the indentity values in it? I never tried that. If it does, it would be a simple matter to store them to another table.

>There's no direct way to do this. @@IDENTITY and SCOPE_IDENTIY() will only catch the last row inserted. You could probably do something with triggers. The INSERTED table will contain the rows that were added. It would just be a matter of matching them up to the actual table to get the identity values.
>
>-Mike
>
>>Hello,
>>
>>I'm building a stored procedure which inserts multiple records in a table from a select statement like this:
>>
>>Insert into TargetTable
>>(Field1, Field2, Field3)
>>Select Fld1, Fld2, Fld3 From SourceTable
>>
>>This works fine, but the targettable has an identity field and I want to store the identity values of the added records in another table. I know I kan do this with Fetch Into, but for performance reasons I would like to build one statement to insert values in the targettable and store the resulting identity values in the other table.
>>Is this possible?
>>
>>TIA,
>>
>>Martin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform