Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to import data from one database to another. On the destination database, I don't have permission to restore a backup file to it, so I have only one option which is to import data.

I used the wizard and I set the option of allow identity insert, but after it ran I faced a problem with foreign keys insertion. Is there anything I missed or shall I drop the foreign keys and recreate it after import?

I really wonder why Microsoft made it complicated.

share|improve this question
    
Have you tried just disabling the FK constraints, import, then enable them again. e.g. serverfault.com/questions/75882/… –  Shawn Melton Aug 25 '12 at 14:12
add comment

2 Answers 2

You could drop the foreign keys, but if the tables are large and/or you have busy environment, be sure to test your insert times before you do anything on production. In regard to new keys, it shouldn't throw a problem, but if you're trying to insert duplicate keys then you'll get errors. Also, be sure to insert parent entities first (if you don't drop foreign constraints first!) then child entities.

share|improve this answer
add comment
**Insert the parent entity first then their child otherwise it will conflict the  **FOREIGN** KEY Constraint.**
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.