PugMaster (2/19/2014)
Hi SeanUnfortunately it is a system I have inherited and the table holds 6.8 million rows there is another column that flags if the second column is a child ID or a parent ID, I'll have a go with a temp table and see what happens.
Kind Regards
Paul
If you have a field in the same table indicating which field is the parent, you can begin with a CTE that gets all the data the same (select field1, field2 where the flag is 0 union all to select field2, field1 where the flag is 1).
Then you don't have to do your recursion twice.