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 2000 Forums
 Transact-SQL (2000)
 Help needed

Author  Topic 

Sutty45
Starting Member

1 Post

Posted - 2005-11-21 : 06:41:55
I currently have a category table in sql server which has basically three columns. and look similar to this.

Cat_ID, Parent_ID, Cat_Name
1,,Category1
2,1,Category2
3,1,Category3
4,2,Category4
5,3,Category5
6,3,Category6
7,5,Category7

I need to be able to get all the children Cat_ID from a given Cat_ID. But as well as its direct children, I want to know there children. So for example if i enter cat_id 3 i'd get 5,6 and 7. Is it possible to do this with tsql or do i require aditional programmig logic?

Any help would be greatly accepted.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-21 : 06:49:52
Refer this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=58007

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-11-21 : 06:51:24
Search here for hierarchies...there's a sticky post from Kristen in the "new to SQL" section which will give you a good link.
Go to Top of Page
   

- Advertisement -