• Junglee_George (2/11/2016)


    The hierarchy is there in the container data.

    The result of #content shows the actual container level hierarchy in the container list starting with the top most level container.

    If we optimize the result of #content, it will be fine. It outputs almost 11000 records.

    Also, avoiding the while loop may further optimize the result.

    The data type of @Partners and @Container is NVARCHAR(MAX)

    Partners value can be like 'EUADVE', 'EUUSEB', 'EUBGLE'

    Containers value can be like 'LOC-DENI-000012', 'LOC-DEST-000002', 'LOC-BRSP-000025'

    Thanks, this is a start. Now, I'd guess that anything other than superficial help is going to cost someone a good couple of hours. Can I suggest you knock up some sample data for them to work with, and provide a more elaborate explanation of what it is you are trying to do here, and how that container hierarchy works? Cheers.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden