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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 N tier query

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-12-07 : 12:32:59
I am trying to write a query that will retrieve all the children for a parent for N level deeps

Basically have accountid, parentid columns

if parentid is null it is the top level

the child at every other level is determined by the parentid column.

how can i write a query that will return the parent and group the children to that parent in order.

basically keep looping until there are no more children in the sublevels -- kind of a like a treeview.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-12-07 : 12:36:06
http://msdn.microsoft.com/en-us/library/ms186243.aspx
Go to Top of Page

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-12-07 : 12:57:48

thanks
Go to Top of Page
   

- Advertisement -