Search code examples
sqlsql-serverssissql-server-data-tools

File identification using part of a filename in SSIS


I hoping someone can help me or can point in the direction as a search didn't return something that was what I was looking for.

I'm still fairly new to SSIS and I've been given the spec of loading three files into separate tables each month. Each month the folder they are in changes and the file name changes. There is also no guarantee that the file name will remain the same going forward.

I have solved the changing folders with various blogs and tips (thanks to the SSIS community!) but I am having trouble identifying which file goes to which table with the names changing.

The three files at the moment are called:

extract_mmes_ae_1415_APPROVED_80_12042016_6.txt extract_mmes_ip_1415_APPROVED_81_12042016_6.txt extract_mmes_apc_1415_APPROVED_82_12042016_6.txt

Next month I expect them to called something like:

extract_mmes_ae_1415_APPROVED_83_12042016_6.txt extract_mmes_ip_1415_APPROVED_84_12042016_6.txt extract_mmes_apc_1415_APPROVED_85_12042016_6.txt

They could also change names and the only thing that will remain consistent is the ae, op and apc sub-strings in the files as identifiers, but the string position could change. My gut is telling me, which could be wrong, is that I need to use a parameter that changes on each time to look for ae, ip and apc in the file name in the flat file source file name and then changes the destination table to be the one for each of three however I have no idea how to get the parameter.

Is any one able to provide a suggestion, or tell me wrong and to look at it another way.


Solution

  • What I think you should do is to creata a Foreach Loop Container to iterate through all files in your folder and either write a script for determining if it's the file you're interested in or not or use a Foreach File Enumerator as mentioned in another question: SSIS Flat File Wildcard Filename