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
 SQL Server Development (2000)
 help with stored procedure

Author  Topic 

sgebbie
Starting Member

7 Posts

Posted - 2002-06-19 : 18:24:12
I am really stuck with this, any help would be appreciated;

I have 2 tables,
Family: Father, Son
Values:Son, value1, value2, value3, value4, value5


I am trying to write a procedure that will perform recursion.

I will supply the Sons name, then I want the function to Add 1 to value1 of his parent, add 1 to value2 of his parents parent, add 1 to value3 of his parents, parents, parent....
etc up 5 levels.

But there is more, some 'family trees' wont go 5 levels up so i must check for this eventuality also.



eventually it should look like


son10, 0,0,0,0,0
son9, 2,1,1,1,1
son8, 1,2,1,1,1
son7, 1,1,2,1,1
son6, 1,1,1,2,1
son5, 1,1,1,1,2



this is way beyond anything i have tried before, so any help would be useful

thanks
Stephen
sgebbie@sglan.freeserve.co.uk

jackstow
Posting Yak Master

160 Posts

Posted - 2002-06-20 : 04:23:28
This article may help - http://www.sqlteam.com/item.asp?ItemID=8866

Go to Top of Page
   

- Advertisement -