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)
1条答案
按热度按时间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