• I don't know much about SSIS but it seems to me that the only way to process things in the correct order would be to "take control" of the situation. With that thought in mind, here's the basic concept for how to create a "Control" table. I can't explain how to use it in SSIS but it seems like it should be an easy thing to "step through" because it would be easy to do in a T-SQL only solution.

    DROP TABLE #Control

    GO

    --===== Simulate a process that captures all of the

    -- file names in a table with an extra column

    -- for processing order.

    SELECT d.PricesFileName

    ,ProcessOrder = CAST(0 AS INT)

    INTO #Control

    FROM

    (

    SELECT 'PRICES_AM_20160622.TXT' UNION ALL

    SELECT 'PRICES_AM_20160623.TXT' UNION ALL

    SELECT 'PRICES_AP_20160622.TXT' UNION ALL

    SELECT 'PRICES_AP_20160623.TXT' UNION ALL

    SELECT 'PRICES_EU_20160622.TXT' UNION ALL

    SELECT 'PRICES_EU_20160623.TXT'

    ) d (PricesFileName)

    ;

    --===== Parse the file names to establish the process order and update the control table

    -- with the correct order.

    WITH cteCreateProcessOrder AS

    (

    SELECT ProcessOrder

    ,RN = ROW_NUMBER() OVER (ORDER BY SUBSTRING(PricesFileName,11,8)

    ,CASE

    WHEN SUBSTRING(PricesFileName,8,2) = 'AP' THEN 1

    WHEN SUBSTRING(PricesFileName,8,2) = 'EU' THEN 2

    WHEN SUBSTRING(PricesFileName,8,2) = 'AM' THEN 3

    ELSE 'UNKNOWN TYPE OF FILE DETECTED'

    END)

    FROM #Control

    )

    UPDATE cteCreateProcessOrder

    SET ProcessOrder = RN

    ;

    --==== Let's see what we have in the #Control table.

    SELECT * FROM #Control ORDER BY ProcessOrder

    ;

    The content of the control table, sorted by the ProcessOrder column looks like this...

    PricesFileName ProcessOrder

    ---------------------- ------------

    PRICES_AP_20160622.TXT 1

    PRICES_EU_20160622.TXT 2

    PRICES_AM_20160622.TXT 3

    PRICES_AP_20160623.TXT 4

    PRICES_EU_20160623.TXT 5

    PRICES_AM_20160623.TXT 6

    (6 row(s) affected)

    --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)