SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Use Database table to dynamically get the excel filename


Use Database table to dynamically get the excel filename

Author
Message
RC-874851
RC-874851
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
Mukti
Mukti
Say Hey Kid
Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)

Group: General Forum Members
Points: 666 Visits: 747
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
jmuldoon
jmuldoon
SSC Journeyman
SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)

Group: General Forum Members
Points: 79 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.
RC-874851
RC-874851
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 42
what enumerator type did you use in the foreach loop
Mukti
Mukti
Say Hey Kid
Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)Say Hey Kid (666 reputation)

Group: General Forum Members
Points: 666 Visits: 747
Excel connection has the ExcelFilePath that you can set dynamically. (Edited by previous answer too).

Use the File Enumerator in ForEach loop.
RC-874851
RC-874851
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
RC-874851
RC-874851
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
RC-874851
RC-874851
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 42
I just gave up and used the normal file load
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search