Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to import Excel's several sheets to DB? Expand / Collapse
Author
Message
Posted Friday, August 29, 2008 2:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, October 18, 2008 6:14 AM
Points: 17, Visits: 105
hi,
I made a package which I import Excel file data (just one sheet) to DB.
and It works fine.
But My Excel file has more than 3 sheets. Each format is the same.
I want package to read all 3 sheets.
Could someone please tell me how to do this??

thank you.:)

Post #561039
Posted Friday, August 29, 2008 7:19 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: 2 days ago @ 9:38 AM
Points: 49, Visits: 202
Take a look at the foreach container. using a variable which you set to each sheet's name or index, you can loop through the sheets and perform the transformation. hope this helps.

Karen
Post #561184
Posted Monday, September 1, 2008 12:18 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, October 18, 2008 6:14 AM
Points: 17, Visits: 105
Hi,Karen.

Thank you very much for replying me.
I found this site : http://msdn.microsoft.com/en-us/library/ms345182.aspx
I tried Foreach Loop Container to loop one data flow which is to read, to transform, and to insert data into DB.
But this was designed only one sheet "Sheet1" s data to be inserted.

after I created a data flow task in a foreach loop container, I executed it.
it seems sheet is looped. I can see the sheet name changes after one loop is done.
But, it is inserting the same sheet's data for 3 times.

do you have any idea where else I need to change??

thank you,
tomoko
Post #561865
Posted Tuesday, September 2, 2008 6:46 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Friday, July 30, 2010 11:27 AM
Points: 435, Visits: 1,403
In keeping with SSIS' apparent campaign to stamp out encapsulation, the sheet name variable is hidden in the Excel Source\Advanced Editor\Component Properties\ OpenRowsetVariable, which in my case I set to User::TabName. (I did not have advanced knowledge of the tabs/range names, which I had to find in a Script task which I copied from a MS MSDN page and set the TabName variable.)

UPDATE:
I probably led you astray with the ablve answer, which I left after inspecting a task in which I also had to specify an Excel sheet name. The more direct way is in the Excel Source Editor (your input data flow task) -- not the Advanced Editor. There, set your "Data access mode:" to "Table name or view name variable", and set the "Variable name:" field to the name of your variable containing the range or sheet name, in my case "User::TabName". Keep in mind that, unlike range names, the Tab Names are suffixed with a "$", e.g. "My Sheet1$".

How in the world does anyone know whether to look in an Editor", an "Advanced Editor, the parameters of a task, or its Expressions to find/use a needed setting? It is madness!
Post #562346
Posted Tuesday, September 2, 2008 9:58 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, August 24, 2013 4:09 PM
Points: 149, Visits: 241
Hi,

I usually do this almost everyday at my job place. I have to get the data from different excel files in one package. I use a very simple method. In the control flow, I drag and drop one dataflow and then I have 3 excel sources in a single data flow task. That means 3 excel connection managers also. And then, I use the data conversion transformation and finally the SQL Server destination. It works fine. I get the data from all three different excel files by executing a single package.

One important thing here. Make sure that in your destination, in the properties window, the tablock option is off. Tablock is on by default, so you need to turn it off or mention it as false in order to get the data from all three sheets.

Hope this works for you too.

Thanks.
notes4we
Post #562488
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse