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 |
|
vinothrao84
Starting Member
21 Posts |
Posted - 2009-07-26 : 23:52:22
|
| hi,Below is my table.Parent ID.......ID.......NameNULL..........10001.....Region1NULL..........10002.....Region2NULL..........10003.....Region310001.........501.......Test110001.........502.......Test210002.........503.......Test310002.........504.......Test410003.........505.......Test510003.........506.......Test6501...........507.......Test7501...........508.......Test8502...........509.......Test9502...........510.......Test10I want the output to be the following.ParentID.......ID.......Name10001..........501......Test110001..........502......Test2501............512......Armenia501............536......BruneiNULL...........10001....Region1Based on where clause for ID = '10001'Pls help. I can't figure out on how to add the last entry of "NULL......10001....Region1"Thx. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-26 : 23:56:53
|
can you explain your logic or what are you trying to do here ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
vinothrao84
Starting Member
21 Posts |
Posted - 2009-07-27 : 00:04:54
|
quote: Originally posted by khtan can you explain your logic or what are you trying to do here ? KH[spoiler]Time is always against us[/spoiler]
hi,thx for the reply.actually i need the output that way in order my asp.net treeview to work properly.thx. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-27 : 00:23:17
|
search this site (use the SEARCH on the TOP RIGHT corner) for recursive cte KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|