I have two table. OLDTABLE and NEWTABLE.
I need to insert some data from oldtable to newtable and the get the ID from new table and update in the oldtable for that corresponding row. the newtable ID has seperate column in oldtable which is null by default.
One way is to get the ID from both table while inserting the data in new table and then later find the data in oldtable and update it. Which is simpler way.
Can anyone suggest some optimized way to do so?
Basically, there is no magic here – you need to insert the rows into
newtableand keep track of the id’s – both the “old” ones from theoldtableas well as the new ones in new table.So basically, you need something like this: