none
Hierarchy Function(s)

    질문

  • Is there any easy way to return the entire Hierachy associated with a specific level within the Hierarchy? So for instance...If I'm at Level 2 say, is there any way to return the associated Level 1...the associated Level 3s...Level 4s...etc..

    Something that would allow me to see all the levels up associated with a certain Hierarchy row and all the levels down with the same Hierarchy row.

    Maybe it's nit as an intuitive as I thought and I have to build level up with an INNER JOIN to the Hierarchy table and an INNER JOIN to GetDescendant as well.

    Thanks for your review and am hopeful for a reply.

    2018년 6월 14일 목요일 오후 6:07

모든 응답

  • you can use logics like this for that

    http://nullablecode.com/2012/05/sql-server-hierarchyid/

    https://blog.tallan.com/2013/10/24/using-the-hierarchyid-sql-server-data-type/


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    2018년 6월 14일 목요일 오후 7:14
  • Those links are good for understanding the fundamentals of the Hierarchy data type. Thank You. But didn't really answer my question. I thought there might be a way to be a little more inquisitive in regards to getting a full ancestry leaf...both parents...siblings...and children...

    There is not a whole lot out here on Hierarchy data type. And I think it's not as inquisitive as one might believe. You still have to build the upward relationships and downward relationships and then if you want that as an entire group perhaps UNION each Select.

    2018년 6월 15일 금요일 오후 12:44
  • Are you using the hierarchy data type?  Can you post a sample of your table(s) and what results you're looking for?
    2018년 6월 15일 금요일 오후 7:40
  • Google "Nested Sets Model" for hierarchies and trees. Or get a copy of my book on Trees & Hierarchies in SQL.

    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    2018년 6월 15일 금요일 오후 8:26
  • Those links are good for understanding the fundamentals of the Hierarchy data type. Thank You. But didn't really answer my question. I thought there might be a way to be a little more inquisitive in regards to getting a full ancestry leaf...both parents...siblings...and children...

    There is not a whole lot out here on Hierarchy data type. And I think it's not as inquisitive as one might believe. You still have to build the upward relationships and downward relationships and then if you want that as an entire group perhaps UNION each Select.

    Since you didnt post your exact scenario with some sample data and what you're trying to achieve, I gave you some links to go through

    If you can put some sample data to illustrate the scenario and explain what you want as output, we can give you sample query


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    2018년 6월 16일 토요일 오전 6:20