问题
In SSIS, I am able to make an insert of rows and retrieve their SCOPE_IDENTITY using OLE DB Command Task which calls stored procedure, but this is not bulk insert, it's slow load. Is it possible to get id of inserted rows using bulk insert in SSIS?
Example: When inserting Customer, first I have to insert record in Person table and then use this FK in Customer table.
UPDATE:
Here's a structure of Person and Customer tables that need to be populated from external source.
One option is to have OriginalId in Person table so that I can use it in lookup when populating Customer table. But that doesn't answer my question about SCOPE_IDENTITY and fast load
回答1:
I would suggest performing your inserts in two separate Data Flow Tasks.
Example:
Data Flow 1 - Insert into Person table
Data Flow 2 - Lookup FK from Person table and then insert into Customer table
来源:https://stackoverflow.com/questions/28583291/scope-identity-for-bulk-insert-in-ssis