recursive queries with out passing root elements

  • hi i am new to sql and face can't find salution for this.i want to diplay first the parant and then all it's subsequent children at different level, then second parant and all it's subsequent children , parent elements is null with levelid=1 i am using sql server 2000,and i don;t want to pass any root elemenet id, it should bring from start to end.

    input

    id name parentid levelid

    1 a NULL 1

    2 b 1 2

    3 c 1 2

    4 d 2 3

    5 e 4 2

    6 f NULL 1

    7 g 6 2

    8 h 7 3

    i want the output like this

    id name parentid levelid

    1 a NULL 1

    2 b 1 2

    3 d 2 3

    4 c 1 2

    5 e 4 2

    6 f NULL 1

    7 g 6 2

    8 h 7 3

  • Posting your question about SQL Server 2000 in the 2005 section wasn't the brightest start possible here!

    Nevertheless, this is a great place to look for recursive/hierarchical techniques on SQL Server 2000:

    http://www.mssqltips.com/tip.asp?tip=938

    Cheers,

    Paul

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

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