SCOPE_IDENTITY() for bulk insert in SSIS

点点圈 提交于 2020-01-17 09:09:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!