i have the following simplified information in a table called suites which unfortunately i cannot control
id  title            parentsuiteid
1   test             NULL
4   pay1             3
5   pay2             3
3   Bill Payments    2
14  Vouchers         2
15  Mini             2
2   Site Tests       NULL
I would like to have a horizontal representation to use for reporting such as
test
Site tests   Bill Payments  pay1
Site tests   Bill Payments  pay2
Site tests   Vouchers   
Site tests   Mini   
i was testing with the join
select a.id,a.title,b.title,a.parentsuiteid from #temp2 a
left outer join #temp2 b
on a.id = b.parentsuiteid
id  title           title       parentsuiteid
1   test            NULL            NULL
4   pay1            NULL            3
5   pay2            NULL            3
3   Bill Payments   pay1            2
3   Bill Payments   pay2            2
14  Vouchers        NULL            2
15  Mini            NULL            2
2   Site Tests      Bill Payments   NULL
2   Site Tests      Vouchers        NULL
2   Site Tests      Mini            NULL 
This works with two levels fine but i cannot predict how many levels in future there will be and it seems to get complicated with more than two
How do i get my output to look like the horizontal representation for +- 5 levels ?
 
     
    