I need to create links between pairs of items and rows of item pairs:
ItemA ItemB
----------------
1 2
1 3
4 5
4 6
6 2
7 8
9 2
9 10
11 12
11 13
14 15
Matching on either side of a pair constitutes a link:
Link A B
---------------
1 1 2
1 1 3
1 4 5
1 4 6
1 6 2
2 7 8
1 9 2
1 9 10
3 11 12
3 11 13
4 14 15
The Link-Item relationship will be stored in the DB as:
Link Item
--------------
1 1
1 2
1 3
1 4
1 5
1 6
1 9
1 10
2 7
2 8
3 11
3 12
3 13
4 14
4 15
Any ideas on the most efficient way to do this (SQL Server 2005)?
ItemA = 1 and ItemB = 2 is the first pair. There are 11 pairs in the set to process. Does that make sense?