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)
 Updating forum records in a recursive manner

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-10 : 09:56:28
Dror writes "Hello,

I am a beginner to triggers. Using MS SQL Server.
I have a forum that I wrote 2 years ago.
It has 70,000 records.

The forum uses a table named Opinion.
The records have a ID, fatherID, IsFather.

I have added a new field "threadID".
The records now have a ID, fatherID, IsFather, threadID.

I want to store in threadID the root entry of the thread - this is the first ID the first (ancient father) message in a topic gets.

I want to recognise all the relevant records from each record in a discussion. All threads will have the uniq ID.

I think of using a triger but I am new to that.

1. if a record is updated and ID = ThreadID and ISfather=1
2. update all child records SET ThreadID = Father's.ThreadID
or
1. if a record is updated ThreadID = 0


2. update all child records SET ThreadID = Father's.ThreadID


this will cause a recursive update to all child records.

Thanks
Dror"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-10 : 09:58:16
See if this helps
http://www.nigelrivett.net/RetrieveTreeHierarchy.html

Madhivanan

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

- Advertisement -