i'm using a sql server 2000. My Tree structured table is here
tItem
ItemID int keyfield,
ParentItemID int,
Title nvarchar 200,
ChildCount int,
Status int
I need to calculate ChildCount and Status trigger. When i insert one item, parent item must calculate child count and status. 0 < status < 100
Calculate parent status that if the parent has 2 child, sum child status and then divide child count. example: 80+100/2 This operation recusive to root parent. for example:
Before :
Project Child=1, Status=80
|-Module Child=1, Status=80
| |-Control Child=0, Status=80
After insert Form item
Project Child=1, Status=90 // 3 Calculate child and status
|-Module Child=2, Status=90 // 2 Calculate child and status
| |-Control Child=0, Status=80
| |-Form Child=0, Status=100 // 1 First. inserted row
This example has 3 level, Maybe my table tree structure level greater then 32
How to create this trigger?