Branislav B.
Branislav B.

Reputation: 558

mass import FOREIGN KEY same table

I have scripted data from a database and want to import them to another, however, I'm getting a FOREIGN KEY SAME TABLE error. After looking at the data I've noticed that FK the row is expecting is created couple of insert statements below. Is there a way to execute the script without having to manually change the order of insert statements?

NOTE: I am using dacpac publish from sqlproj (SDK)

Upvotes: 0

Views: 72

Answers (1)

Branislav B.
Branislav B.

Reputation: 558

Disable the constraint check first

ALTER TABLE dbo.myTable NOCHECK CONSTRAINT FK_myTable_myTable GO

then enable it using

ALTER TABLE dbo.myTable CHECK CONSTRAINT FK_myTable_myTable GO

Upvotes: 0

Related Questions