Thursday, 5 September 2013

Importing Excel file with dynamic name into SQL table via SSIS?

Importing Excel file with dynamic name into SQL table via SSIS?

I've done a few searches here, and while some issues are similar, they
don't seem to be exactly what I need.
What I'm trying to do is import an Excel file into a SQL table via SSIS,
but the problem is that I will never know the exact filename. We get files
at no steady interval, and the file usually has a date/month in the name.
For instance, our current file is "Census Data - May 2013.xls". We will
only ever load ONE file at a time, so I don't need to loop through a
directory for multiple Excel files.
My concept is that I can take this file, copy it to a "Loading" directory,
and load it from there. At the start of the package, I will first clear
out the loading directory, then scan the original directory for an Excel
file, copy it to the loading directory and then load it into SQL. I
suppose I may have to store the file names somewhere so I don't copy the
same file into the loading directory in subsequent months, but I'm not
really sure of the best way to handle that.
I've pretty much got everything down except the part that scans the
directory for the Excel file and copies it to the loading directory. I've
taken the majority of my info from this page, which (again) is close to
what I want to do but not quite exactly the solution I need.
Can anyone get me over the finish line? I can't seem to get the Excel
Connection Manager right (this is my first time using variables), and I
can't figure out how to get the file into the Loading directory.

No comments:

Post a Comment