How can I specify a variable file name using SSIS?
-
23-08-2019 - |
Question
I'm a newbie to using SSIS for data imports - I have a couple of files that I want to import into my database schema, but I'm going to need to run this once every 3 months; the file names change based on the quarter e.g. SKU1QTR
will become SKU2QTR
.
How can I handle a situation like this with SSIS? Is there a way to specify the file names (there are at least 6 files like this) or, better yet, just specify the numeric portion since the rest of the file always stays the same?
Solution
Create a script task and do something like this, where FlatFileCSV would be the name of your connection
Dts.Connections("FlatFileCSV").ConnectionString =
"E:\SomeFile" + theDate.ToString("yyyyMMdd") + ".csv"
OTHER TIPS
Put your filename/connection string in a configuration file. If that truly is the only thing that is different, then you can even run the package from command line and you won't need to open BIDS at all.
As you are a self described newbie, this is a bit more advanced, but it is a technique worth knowing.