SSIS pick csv file

NickK 176 Reputation points

hi experts, I need some tips on the below request.

I have a ssis task in which I use SFTP task to download files from FTP to D:\Dowload\ and the file format is CSV with a date.
Filename_22020930_Final.csv, and next week or day the file will be Filename_22021007_Final.csv or something like that (filename_date.csv)

I am wondering how to get data from files with dates. source CSV and destination SQL table
Currently- I have a ssis package with the file name Filename.csv and it's working fine but the requirement changed that the file will have dates.
can someone help me get the source CSV files with the date?


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,883 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,466 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,563 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 33,386 Reputation points

    Hi @NickK ,

    If the file name is based on the date, we could first save below expression to a variable first.

    + (DT_STR, 4, 1252) DATEPART("yyyy" , GETDATE())  
    + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2)  
    + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2) + "_Final.csv"  

    On the Flat File connection manager, add the string variable as the expression for the connection string. This can be done from the Properties window (press F4) on the connection manager, going to the Expressions field, pressing the ellipsis next to it, choosing the ConnectionString property on the next window and selecting the recently created string variable as the expression for this.


    Also remember to set the DelayValidation Property to true.

    A sample here:

    Zoe Hui

    If the answer is helpful, please click "Accept Answer" and upvote it.

  2. Jingyang Li 5,891 Reputation points

    You can try to import a file dynamically without knowing the file name in this discussion:

    0 comments No comments