4

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

Diego
  • 34,802
  • 21
  • 91
  • 134
justSteve
  • 5,444
  • 19
  • 72
  • 137
  • http://stackoverflow.com/questions/737115/turn-off-constraints-temporarily and you can use DBCC CHECKCONSTRAINT to check that all is well before you turn them back on – τεκ May 23 '13 at 19:56

1 Answers1

4

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

Diego
  • 34,802
  • 21
  • 91
  • 134