0

I have created one database by executing generated script(schema).

After that I am copying database,only data while copying I facing problem of foreign key violation and primary key violation

What should I do for this issue.

key Violation

G dangi
  • 188
  • 7
  • 19

1 Answers1

0

You really only have two options here, go though the data your importing and change the conflicting value or drop the constrains all together. Once the data is in the new DB you can not enable constraints until you address the duplicate data. See this SO for in on removing FKs, it also applies to dropping PKs

How do I drop a foreign key in SQL Server?

I would highly recommend seeing if you can change the data so it no longer violates the key constrains

Community
  • 1
  • 1
Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123