سؤال

I have the following table:

EntityId - PK
Label
ParentEntityId - FK

ParentEntityId is joined to EntityId of the same table. now I am having problems importing data to this table using SSIS because of instances where the parent entities haven't been imported yet and so I get a FK constraint violation. I'm probably missing something obvious.

هل كانت مفيدة؟

المحلول

You can disable the foreign key prior to loading the data, then re-enable it after loading completes, both using T-SQL.

Eg - to disable - ALTER TABLE yourTableName NOCHECK CONSTRAINT yourConstraintName

To re-enable - ALTER TABLE yourTableName WITH CHECK CHECK CONSTRAINT yourConstraintName

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top