Need Help Passing Parameter in CTE Recurrsive Query

  • Hello,

    I need some help to get the Hierarchy information (Recurrsive table data) in a standard format.

    The Recursive table with the following column names

    ID,Description,ParentID,Depth

    I have the following values

    1 USA    NULL   0

    2 FL       1       1

    3 CA      1       1

    4 GA      1       1

    5 Miami  2       2

    6 Tampa  2     2

    7 PlanA  5      3

    8 PlanB  6      3

    I would like to pass USA ,Fl, Miami as a parameter and Get the Plan Information. I have written the CTE qry to pull the Hierarchy information for USA, But I don't know how to pass the 2nd parameter and get into the next level.

    Could you guys help me?

    Thanks

  • This was removed by the editor as SPAM

  • Can you post the query you've written?

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • with NewTree (intValOptionDetailID,strDescription,intParentOptionDetailID,intTreeDepth)

    as

    (

    Select

    A.ID,

    A.Description,

    A.ParentID,

    A.Depth

    from dbo.Table1 A

    where A.ID = 1

    Union All

    Select

    A.ID,

    A.Description,

    A.ParentIDID,

    A.Depth

    from dbo.Table1 A,

    NewTree B

    where A.ParentID = B.ID

    AND A.Depth >= B.Depth

    )

    Select * from NewTree

    The above qry gives me the whole tree, But We would like to pass 3, 4..n parameter to get the Next node.

    We receive the customer information in a text file with their geographical details and We need to compare the data with our tree structure and assign the plan based on their geo' locations.

    It is easy to join the data with a flat table and get the Plan. We want to have a flexible model where we don't need to change the model often.

    Is there any other options, where I could reach the END NODE?

    Thanks

Viewing 4 posts - 1 through 3 (of 3 total)

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