Sql-server – Import data problem in SQL Server 2008

importsql serversql-server-2008

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.

Best Answer

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.