Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Dev@nlkss
134 Posts |
Posted - 2009-03-23 : 06:54:00
|
Hi allI have a table with follwoing data.ID - ParentID - Name1 - 0 - A2 - 1 - B3 - 1 - C4 - 2 - Di.e A is the root level item and it has children of B,C.I have to display as followsA->BA->CB->D How can i display as above.thanks in advance.$atya.Love All Serve All. |
|
ra.shinde
Posting Yak Master
103 Posts |
Posted - 2009-03-23 : 07:09:46
|
DECLARE @TAB1 TABLE(ID int,ParentID int,Name varchar(10))INSERT INTO @TAB1select 1,0, 'A'unionselect 2,1,'B'unionSELECT 3,1,'C'unionselect 4,2,'D'select parent.name,child.name from@TAB1 parentinner join @TAB1 child on child.ParentID = parent.idRahul Shinde |
 |
|
|
|
|