I’m trying to seed a blank database from the production db via the Import/Export wizard. How do I convince SQL Server to ignore Foreign Key violations?
thx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is an option to “check constraints” on the OleDbDestination Component. unmark it and it will ignore the foreign keys.
I honestly don’t like that option much, so I suggest these two other ways:
1) Always copy the tables on the “inverse” order of the key. For example, if you have a key from A to B, copy table B first and then table A
2) use a Exec SQL Task to disable the foreign keys with the
NOCHECK CONSTRAINT(example here) before copy and another to enable after copy