Search code examples
sql-serverssisetlflatfilesource

How I can configure flat file name as filename_*.txt in SSIS


I have flat file source and connection manager. I need to configure its connection string as filename_* .txt. I have one variable on package level to read the directory path and then I am using it in expression property to read the file path as @FilePath + "filename__* " + ".txt". This is not working. I am not able to figure out how to configure file name as filename_*.txt.


Solution

  • In a case like this best practice is to use a foreach loop container of type File Enumerator, you can pass it a search string to scan for files and run a process using the found file name.

    Note if you have multiple files in that folder it will run the same process for each file

    For Each Container of type File Enumerator

    The container will then execute everything inside it for each file found with that search string. You will need to map the found file name to a variable on the Variable Mapping section.

    Map Variable

    You can now use the variable as an expression in your file connection

    Your control flow should look like this

    Control Flow