|
Posted by Erland Sommarskog on 05/25/05 23:46
coosa (coosa76@gmail.com) writes:
> To illustrate a pseudo code, i attempt the following:
> 1.) Iterate through all rows, row by row
> 2.) create a temporary variable to equal the current id
> 3.) Begin a loop in each row
> 4.) create a counter and initialize to equal 1
> 5.) For each row, set the temporary variable to equal the parent id (as
> linked lists)
> 6.) increment the counter
> 7.) End the loop if the temporary variable is null (means it reached
> the root category that has no further parents)
> 8.) Update the depth of that particular row to equal the counter
> 9.) continue to iterate through the rest of all remaining rows
>
> How can i do it? :-)
The standard recomendation is that you post:
o CREATE TABLE statement for your table(s), possibly simplified.
o INSERT statements with sample data.
o The desired result given the sample.
o A short narrative that explains what you are trying to achieve from
a busniess-rules perspective.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
[Back to original message]
|