Recursive Query to SSIS steps from Raw Data Source

  • Hello,

    Can anyone please help me to (Pseudocode will be perfect) to translate below query to SSIS steps?

    My Data Source is is Raw file and output will be in Raw file too. I can use Cache Connection to cache the whole dataset if needed.

    I am familiar with SSIS steps but never did Recursive 🙁

    Source file structure:

    AgentId,UplineAgentId,Position

    Recursive CTE Query:

    ;WITH AgentsWithSelfUprRecords AS

    (

    SELECT AgentId

    FROM pfsHier

    WHERE AgentId = UplineAgentId AND Position = 'UPR'

    ),

    T AS

    (

    SELECT H.UplineAgentId, H.AgentId, 1 As Depth

    FROM AgentsWithSelfUprRecords A

    INNER JOIN pfsHier H ON H.UplineAgentId != H.AgentId AND H.AgentId = A.AgentId AND H.Position = 'UOS'

    UNION ALL

    SELECT T.UplineAgentId, H.AgentId, T.Depth + 1 AS Depth

    FROM T

    INNER JOIN pfsHier H ON H.AgentId != H.UplineAgentId AND H.UplineAgentId = T.AgentId AND H.Position = 'UPR'

    )

    SELECT *

    FROM T

    UNION ALL

    SELECT A.AgentId AS UplineAgentId, A.AgentId, 0 AS Depth

    FROM AgentsWithSelfUprRecords A

    ORDER BY UplineAgentId, Depth

    Thanks and any help will be much appreciated.

    Thanks again,

    Z

  • zahidullislam (1/11/2011)


    Hello,

    Can anyone please help me to (Pseudocode will be perfect) to translate below query to SSIS steps?

    My Data Source is is Raw file and output will be in Raw file too. I can use Cache Connection to cache the whole dataset if needed.

    I am familiar with SSIS steps but never did Recursive 🙁

    Source file structure:

    AgentId,UplineAgentId,Position

    Recursive CTE Query:

    ;WITH AgentsWithSelfUprRecords AS

    (

    SELECT AgentId

    FROM pfsHier

    WHERE AgentId = UplineAgentId AND Position = 'UPR'

    ),

    T AS

    (

    SELECT H.UplineAgentId, H.AgentId, 1 As Depth

    FROM AgentsWithSelfUprRecords A

    INNER JOIN pfsHier H ON H.UplineAgentId != H.AgentId AND H.AgentId = A.AgentId AND H.Position = 'UOS'

    UNION ALL

    SELECT T.UplineAgentId, H.AgentId, T.Depth + 1 AS Depth

    FROM T

    INNER JOIN pfsHier H ON H.AgentId != H.UplineAgentId AND H.UplineAgentId = T.AgentId AND H.Position = 'UPR'

    )

    SELECT *

    FROM T

    UNION ALL

    SELECT A.AgentId AS UplineAgentId, A.AgentId, 0 AS Depth

    FROM AgentsWithSelfUprRecords A

    ORDER BY UplineAgentId, Depth

    Thanks and any help will be much appreciated.

    Thanks again,

    Z

    I can't help much with SSIS because I don't use it and I sure don't know what UPR or UOS is. I can tell you that the CTE called "T" is a recursive CTE designed to produce a hierarchical listing.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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