I have an issue in insertion of records from one table to another the tables schema is same
Table 1
Id Parent Id Text
11 Null A
12 Null B
13 11 C
14 11 D
15 13 E
The record should be inserted in this format, According to my knowledge I have to copy the foreign key relation not the identities of it.
Table 2
Id Parent Id Text
31 Null A
32 Null B
33 31 C
34 31 D
35 33 E

Umang TandonPosted Jun 12, 2019, 7:38 AM
I have found a solution to this question.
Steps: Insert the Text column values into the main table, leaving the ParentId as null and at the same time insert the values into a Dictionary as oldId key and New Inserted Id as value to the corresponding key.
After insertion Update the values on the basis of the mapped Dictionary keyValue Pair
Umang TandonPosted Jun 6, 2019, 7:57 AM
Ronika JencyPosted Jun 6, 2019, 6:09 AM
Umang TandonPosted Jun 6, 2019, 5:40 AM
Ronika JencyPosted Jun 6, 2019, 5:24 AM
Umang TandonPosted Jun 6, 2019, 4:20 AM
Both the tables have same schema same primary(ID) foreign key(ParentId) realtion.
The approach which I am currently using is recursive approach first insert the text and keep the parent id null and after this I will get the newly generated id in the new table and then I will update it (this part I am not able to understand that how i have to do) am I following the right approach?
Any help will be appreciated thanks.
Ronika JencyPosted Jun 6, 2019, 1:04 AM