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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 counting child nodes in Hierachy

Author  Topic 

jameswoodmancy
Starting Member

13 Posts

Posted - 2008-05-20 : 06:16:27
Hi,
I have a SQL statement that returns a hierachy

it returns ..

-NEWSPAPER
-QUALS
- TIMES
- TELEGRAPH
-MIDS
- DAILY MAIL
- EXPRESS
- EVENING STANDARD
- POPS
- THE SUN

I want the statement to include childnumber column so for newspaper it would count the total number of children below it, so in the above example newspaper would be 9 and for the mids it would equal 3? and pops = 1. does anyone know how i can do this in SQL?

thanks for your help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-20 : 06:45:42
Look for recursive CTE on books online.
Go to Top of Page
   

- Advertisement -