• Celko and Sean,

    Thanks for the responses, I'm sorry i don't think i was clear enough, what I have is something like

    ID ParentID Hierarchy

    1 NULL 1

    2 1 1.2

    3 2 1.2.3

    4 1 1.4

    ...

    what first querie does is a like on Hierarchy column, what mine does is a rcte from ID to ParentID pretty much like BOL examples... what I really don't understand is why query optimizer tells me the rcte is cheaper execution wise whilst it produces way more IO and CPU time than the like approach, by that i mean that this :

    SELECT

    stChild.OUID,

    stChild.OUParentID,

    stChild.CustomerID,

    stChild.Name,

    stChild.NameFull,

    stChild.Hierarchy,

    stChild.HierarchyDepth,

    stChild.Enabled,

    st.OUID as OUIDAncestor

    FROM SomeTable st

    INNER JOIN SomeTable stChild ON stChild.Hierarchy + '.' LIKE st.Hierarchy + '.%'

    produces less IO and CPU time than a cookie cutter rcte having a anchor on top-level rows and recursing on childs

    Edit : just setting sql code in the right container ( was in a quote )