|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, November 21, 2008 8:02 AM
Points: 10,
Visits: 42
|
|
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
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:09 PM
Points: 226,
Visits: 707
|
|
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
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, December 14, 2009 2:47 PM
Points: 11,
Visits: 50
|
|
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.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, November 21, 2008 8:02 AM
Points: 10,
Visits: 42
|
|
| what enumerator type did you use in the foreach loop
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:09 PM
Points: 226,
Visits: 707
|
|
Excel connection has the ExcelFilePath that you can set dynamically. (Edited by previous answer too).
Use the File Enumerator in ForEach loop.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, November 21, 2008 8:02 AM
Points: 10,
Visits: 42
|
|
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
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, November 21, 2008 8:02 AM
Points: 10,
Visits: 42
|
|
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
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, November 21, 2008 8:02 AM
Points: 10,
Visits: 42
|
|
| I just gave up and used the normal file load
|
|
|
|