Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to import Excel's several sheets to DB?


how to import Excel's several sheets to DB?

Author
Message
tomoko667
tomoko667
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
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.Smile
mz1derful
mz1derful
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 236
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
tomoko667
tomoko667
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
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
Jim Russell-390299
Jim Russell-390299
SSC-Addicted
SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)

Group: General Forum Members
Points: 449 Visits: 1403
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!
notes4we
notes4we
SSC-Enthusiastic
SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)SSC-Enthusiastic (153 reputation)

Group: General Forum Members
Points: 153 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
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