Loop through flat files SSIS

  • Hi,

    I have to process some flat files from a network folder based on date range and some variable number formats.

    e.g D220531.ABCD.MH0A,

    D220531.ABCD.MH0C,

    D220531.ABCD.MH0G,

    D220531.ABCD.MH0B,

    D220531.ABCD.MH01,

    D220531.ABCD.MH02,

    D220531.ABCD.MH04,

    D220531.ABCD.MH05

    0531 = last day of previous month

    They are inserted into staging first and then into the main table.

    I have done everything that needs to be done to import the data except handling these variable filenames.

    I am using a foreach loop container and using a variable filename to get the filename.

    Please help.

  • I'm not entirely sure I understand what the question was.

    You're on the right track, as far as I can tell. You want the ForEach Loop control in the Control Flow. In there, you can wildcard pattern to D22*.ABCD.MH* from your load directory. You can also control it via variables and expressions to be more complex and precise.

    Where are you having trouble in particular?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • How to use wildcard pattern in Foreach loop container ? I am stuck here. 🙁

    Should I use Enumerator configuration : Name and extension only ?

  • PSB (6/13/2011)


    How to use wildcard pattern in Foreach loop container ? I am stuck here. 🙁

    Should I use Enumerator configuration : Name and extension only ?

    Kinda.

    In the FILES component, you can use wildcarding on the file name. In the Folder component, you path it to where to loop at.

    The Name and Extension part is what you want it to return to your variable that you'll use elsewhere: as the name in the expression in the flat file connection, for example. For that I'd use Fully qualified so I didn't have to re-read the pathing.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • I'm sure I'm late, but I'll try anyway.

    Make sure you map a variable to that file name in your container and that the variable is scoped at least as high as the container level (package level if you'll be using the file name outside the container). Otherwise, the tasks in the container that might be looking for that file name, or path & filename, won't be able to find it.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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