------>>>How to write this query?

  • Hi Guys,

    I have a table with the following structure and data:

    ID ParentID

    1 0

    2 0

    3 0

    4 1

    5 1

    6 1

    7 2

    8 3

    9 4

    10 4

    11 4

    12 10

    13 10

    14 12

    ...

    I need to write a query or stored procedure to get a full tree of a given ID, for example, if the given ID is 1, it should return:

    1 0

    4 1

    5 1

    6 1

    9 4

    10 4

    11 4

    12 10

    13 10

    14 12

    How do I do this?

    Thanks.

  • Since you're in 2000 - you're going to need to use something iterative to go out and pull in the various levels of children.

    You seem to be describing the expanding hierarchy issue. Microsoft actually has a description of how to pull this data. It's found here:

    http://support.microsoft.com/kb/248915

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply