SQL Server mass import FOREIGN KEY same table

6ojccjat  于 2023-06-21  发布在  其他
关注(0)|答案(1)|浏览(138)

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)

h79rfbju

h79rfbju1#

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

相关问题