September 10, 2008 at 7:25 am
I'm trying to build a package that loads a sheet from excel into SQL Server table. Each of our locations submits a file to the network. However some locations will go away and others may be added so I wanted to make the filename list table driven. I have the data flow working that successfully loads the spreadsheet but now I'm looking for a method to get the excel filename from a table. I was testing with the execute sql .
Thanks for any help
Richard
September 10, 2008 at 11:26 am
Use expression to set the connection string for your excel connection. Use a variable to set the conection string. You can do this by Properties->Expressions->ExcelFilePath-> Set your vairble here.
Now use Execute SQL Task to set the value of this variable. In the Execute SQL Task Editor, set the ResultSet as SingleRow, now click on Result Set on the side menu and click Add to add a vairble mapping. If you are uisng OLEDB conneciton use 0 as Resultset name and select your variable.
This should set the variable to a value from your table and will set the Excel File Path for excel to this value.
HTH
Mukti
September 10, 2008 at 12:42 pm
The way that I've done this successfully in the past was to use the expressions to replace the Excel Filename property with the filename from some variable.
My observation has been that the connection string property for a spreadsheet does not ever contain a filename, even when using a static filename. (but that is not to say that SSIS does not add the filename property to the connection string at runtime to produce it.
At least that how i've done it in a ForEach container and it has always worked. Never had to do anything with the connect string property, only the filename property.
September 10, 2008 at 2:52 pm
what enumerator type did you use in the foreach loop
September 10, 2008 at 3:45 pm
Excel connection has the ExcelFilePath that you can set dynamically. (Edited by previous answer too).
Use the File Enumerator in ForEach loop.
September 12, 2008 at 10:11 am
Thanks for the help so far but the for each does not seem to make sense. Once I make the setting foreach file, it now reads each file in the directory. I want it to get the filename from the database select which brings back more than one row.
Richard
September 12, 2008 at 1:51 pm
Reading on in the help about the exec sql task it says if you bring back more than one row you must define a variable of type object , then use script to extract the data. I'm now confused on how the orginal suggestion in his post could work.
Any help appreciated.
Thanks
September 12, 2008 at 3:34 pm
I just gave up and used the normal file load
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply