lsmyth1717
Programmer
I've got a real brain teaser which I'm trying to work out. Basically I recieve a merge table in every night which supplies a list of urns which have been merged into other urns. I'm using a .net application to search on urns and return results but when a user input a urn my stored procedures looks up the merge table below and sees whether the urn exists and if it does then it goes to the tourn and sees whether another entry of it exists in the table and it works its way through until it arrives at the last tourn and it displays the results based on that urn.
My problem is that i need to jump about a lot to get to the right urn. For example based on below: -
Could go from 100 - 200, then 200 -300 and finally 300 -400 before I get the correct urn to display.
Ideally i'd like to create a new table shown below as move table which holds the final to-urn for each instance and no jumping about is required. I think the table below helps to describe what I am trying to achieve.
My problem is I am having difficulty coming up with an insert statement or algorithim which does the insert from Merge table to Move table. Can anyone please help me with this as i'm not to hot with sql.
Merge Table
MergeFromURN MergeToURN MergeDateMerged
100 200 15/06/1982
200 300 15/06/1982
300 400 15/06/1982
500 600 15/06/1982
700 100 15/06/1982
Move Table
MoveFromURN MoveFromURN MoveDateMerged
100 400 15/06/1982
200 400 15/06/1982
300 400 15/06/1982
500 600 15/06/1982
700 400 15/06/1982
My problem is that i need to jump about a lot to get to the right urn. For example based on below: -
Could go from 100 - 200, then 200 -300 and finally 300 -400 before I get the correct urn to display.
Ideally i'd like to create a new table shown below as move table which holds the final to-urn for each instance and no jumping about is required. I think the table below helps to describe what I am trying to achieve.
My problem is I am having difficulty coming up with an insert statement or algorithim which does the insert from Merge table to Move table. Can anyone please help me with this as i'm not to hot with sql.
Merge Table
MergeFromURN MergeToURN MergeDateMerged
100 200 15/06/1982
200 300 15/06/1982
300 400 15/06/1982
500 600 15/06/1982
700 100 15/06/1982
Move Table
MoveFromURN MoveFromURN MoveDateMerged
100 400 15/06/1982
200 400 15/06/1982
300 400 15/06/1982
500 600 15/06/1982
700 400 15/06/1982