Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 23-Apr-12 20:15pm
AZAD881.1K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  
Comments
AZAD88 at 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)

  Print Answers RSS
0 Maciej Los 474
1 ridoy 420
2 DamithSL 180
3 OriginalGriff 179
4 Richard MacCutchan 160
0 OriginalGriff 8,033
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,538
3 Maciej Los 5,508
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 24 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100