Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,
As i need to know the database Foreign keys & Primary keys list due to i need to insert from database1 to database2 at that time i need to drop the Foreign keys, Primary keys off the database2 so that i can insert the Data's of database1 after that i need to recreate the keys

Note : i got the query for foreign keys list but when i try to drop Foreign keys at that time i getting primary key reference error

thanking you for your help soon!!
Posted

Who suggested/asked you to do the migration this way? Do you have any idea on how much data issues can be introduced this way? There was/is a reason why Primary key & Foreign keys are defined. I would not suggest you to do this way at all.

Instead try:
1. Have a look at the database design properly. make a list of tables in a sequence where the lowest tables having maximum dependencies and top once being kind of master table with only primary keys.
2. Populate/Migrate the table from top to bottom order - First the master tables and then the dependent tables.

This way you wont need to drop any key and the data would have least chance of getting corrupt.

I would suggest you to talk to your senior and get more guidance in case you need more help on the same.
 
Share this answer
 
It is generally a bad idea to do this, but sometimes you need to do it for bulk inserts.

You can disable constraint checking, see here :
http://weblogs.sqlteam.com/joew/archive/2008/10/01/60719.aspx[^]
 
Share this answer
 
Comments
AZAD88 24-Apr-12 4:21am    
Thanks for u r comments i have already analysis issues & i have explained too but no use here i am in freak situation that y i posted with a hope !!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900