Scenario:
We have our source Excel file that has sale history. Each sheet will has data for a year. We can get data for any number or years. In this example we have data for three years. We need to load this data to our destination table.
Source Excel File looks like this
Destination Table definition:
CREATE TABLE dbo.SaleHisTory
(
ID INT IDENTITY(1, 1),
SalePersonName VARCHAR(100),
SaleCountry VARCHAR(50),
SaleAmt INT,
SheetName VARCHAR(100)
)
Solution :
We will be using Foreach Loop Container to perform this requirement. Let's start with step by step approach
Step 1:
Create connection to our Excel source file as shown below
Choose Microsoft Office 12.0 Access Database Engine OLE DB Provided as shown below
Press Ok as shown above in number 3. Provide the File Path as shown below
Click on All and Provide values as shown below
We are all done with configuring our Excel File Connection.
Step 2:
Bring For each loop container to the Control Flow Pane and configure as shown below
Enumerator : Foreach ADO.NET Schema Rowset Enumerator
Connection String : The OLE DB Connection String that we have created in Step 1
Schema : Tables As we are interested to get the names of sheets
Go to Variable Mapping and map the variable to Table_Name as shown below
Set Index from 0 to 2 as Table_Name is on third number in List
Step 3:
Bring Data Flow Task to Control Flow pane inside Foreach Loop Container. Open Data Flow by double Clicking and then bring ADO.NET Source as shown below and configure. One thing to notice here, we do not have option to provide variable in which we have saved our SheetName , For now Choose any sheet you like as all Sheets in Excel are with same metadata.
Drag Derived Column Transformation to Data Flow pane and Connect ADO NET Source to it. Perform data conversation according to destination columns and also generate new column DER_SheetName by using SheetName variable.
After that bring OLE DB Destination and connect Derived Column Transformation to it and map the columns.
Step 4:
Till here our package is ready but only Table Name(SheetName) is hard coded in our ADO NET Source. We want to change it to SheetName Variable so with each iteration it should change so we can load all the Excel sheets.
To do that , Click on Data Flow Task and go to properties and then Expression and configure as shown.
Set the data flow property Delay Validation=True so it should not validation as sheet names will be provided while execution not at start of package validation.
Final Output :
Execute package and check the destination table if all the records from all excel sheets are loaded successfully.
Data is successfully loaded to dbo.SaleHistory Table from three sheets 2011,2012,1013 as shown below.
Video Demo for " How to Load Multiple Sheets to a SQL Server Table"
Check out our other posts/ Videos related to Excel Source and Destination
- How to Load Data from Excel Files when Number of Columns can decrease or order is changed in Excel Sheet
- How to Load Only Matching Column Data to SQL Server Table from Multiple Excel Files (Single Sheet per file) Dynamically in SSIS Package
- How to Load Excel File Names with Sheet Names ,Row Count,Last Modified Date, File Size in SQL Server Table
- How to Load Multiple Excel Files with Multiple Sheets to Single SQL Server Table by using SSIS Package
- How to Load Matching Sheets from Excel to Table and Log Not Matching Sheets Information in SQL Server Table
- How to create Table for each sheet in Excel Files and load data to it dynamically in SSIS Package
- How to Create Table per Excel File and Load all Sheets Data Dynamically in SSIS Package by using Script Task
- How to create CSV file per Excel File and Load All Sheets from Excel File to it in SSIS Package
- How to Create CSV File for Each Excel Sheet from Excel Files in SSIS Package
- How to Load Excel File Name and Sheet Name with Data to SQL Server in SSIS Package
- How to Import data from Multiple Excel Sheets with a pattern of sheet names from Multiple Excel File in SSIS Package
- How to import Data from Excel Files for specific Sheet Name to SQL Server Table in SSIS Package
- Load Data To Tables according to Excel Sheet Names from Excel Files dynamically in SSIS Package
- How to Load Excel Files with Single/ Multiple Sheets to SQL Server Tables according to Excel File Name Dynamically
- How to Read Excel Sheet Data after Skipping Rows in SSIS Package by using Script Task
- How to read data from Excel Sheet and Load to Multiple Tables by using Script Task in SSIS Package
- How to create Excel File Dynamically from SQL server Table/View by using Script Task in SSIS Package
- How to create Excel File Dynamically for Stored Procedure Results in SSIS Package by using Script Task
- How to Export SQL Server Tables from Database to Excel File Dynamically in SSIS Package by using Script Task
- How to Convert CSV/Text Files to Excel Files in SSIS Package by using Script Task
- How to Load All CSV Files to Excel Sheets ( Sheet Per CSV) in single Excel File in SSIS Package
- How to Load All CSV Files to Single Excel Sheet with File Names in an Excel File Dynamically in SSIS Package
- How to Create Sample Excel file with Sheet from each table with Top 1000 Rows per sheet in SSIS Package
- How to Export Data to Multiple Excel Sheets from Single SQL Server Table in SSIS Package
- How to split large table data into multiple Excel Sheets on Single Excel File by using SSIS Package
- How to Export All tables of a database to Excel Files with Date-time in SSIS Package
Amazing experience on reading your article. It is really nice and informative.
ReplyDeletePython Training in Chennai
Python Training in T.Nagar
JAVA Training in Chennai
Big data training in chennai
Selenium Training in Chennai
Python Training in Chennai
Python Training in Tambaram
really nice post...Thanks for sharing...
ReplyDeletePython training in Chennai/Python training in OMR/Python training in Velachery/Python certification training in Chennai/Python training fees in Chennai/Python training with placement in Chennai/Python training in Chennai with Placement/Python course in Chennai/Python Certification course in Chennai/Python online training in Chennai/Python training in Chennai Quora/Best Python Training in Chennai/Best Python training in OMR/Best Python training in Velachery/Best Python course in Chennai/<a
We Offered Python Training in Gurgaon with Top Trainers at Low Cost. This Python Course will help you to Learn Python Programming from scratch in a Practical Manner. Our Python Training teaches you how to write Python Coding for Data Science, Machine learning algorithms, web scratching, Deep learning, and AI Techniques. Through this Python Classroom Training in Gurgaon, you will get 100% Placement from our tied up company.
ReplyDeleteFor More Info: Python Training in Gurgaon
i was just browsing along and came upon your blog. just wanted to say good blog and this article really helped me.
ReplyDeleteexcel institute in gurgaon
Courseafter12th institute offers Best Web Designing in Delhi. We offer website design education for bringing experts. Call Now & GET SCHOLARSHIP DISCOUNT ON DIPLOMA COURSES at 8860222625.
ReplyDeleteBest Web Designing in Delhi
Best E-accounting Institute in Delhi
Best Tally Course in Delhi
I feel SSIS is the best and most useful aspect of providing and finding solutions about some complex IT problems.
ReplyDeleteSSIS Postgresql Read
Great Article
ReplyDeleteFinal Year Projects in Python
Python Training in Chennai
FInal Year Project Centers in Chennai
Python Training in Chennai
You have even succeeded to make it reasonable and peaceful to read. Will surely come and visit this blog more often. Thanks for sharing. Otherwise if anyone want to Learn Advanced Excel So You Contact Here-+91-9311002620 Or Visit Website- Click Here- Advanced Excel Training Institute in Delhi
ReplyDeleteMua vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ Vietnam Airline
vé máy bay tết 2021 Vietnam Airline
vé máy bay đi San Francisco giá rẻ 2021
vé máy bay đi Pháp giá rẻ
vé máy bay đi Anh bao nhiêu
ve may bay di Los Angeles
combo đà nẵng 3 ngày 2 đêm
combo du lịch nha trang 4 ngày 3 đêm
visa trung quốc 30 ngày
cách ly khách sạn
Wonderful post and more informative!keep sharing Like this!
ReplyDeleteFull stack developer course in bangalore
Full stack developer course in pune
Full stack developer course in Gurgaon
Full stack developer course in hyderabad
Full stack developer course in delhi
Full stack developer course in Trivandrum
Full stack developer course in kochi
Full stack developer course in mumbai
Full stack developer course in ahmedabad
The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought you have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention. advanced excel training in gurgaon
ReplyDeleteI really appreciate your hard work you put into your blog and detailed information you provide. Further More Information About MIS training institute in Delhi Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/business-analytics/MIS-training-instiute-in-delhi
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteT-Shomedia is a Manchester web design and development company that offers a range of services to businesses and individuals. We specialise in custom web design, online marketing, SEO, and online advertising. We have experience working with a variety of different industries, so we can provide you with the perfect solution for your website or online presence. Contact us today to learn more about our services!
ReplyDeleteinformative content, keep sharing UI/UX course in pune
ReplyDeleteAre you eager to embark on a transformative journey into the world of web development? Look no further! Our comprehensive web development courses in Kochi offer not only top-notch learning but also an exclusive opportunity for a free internship.
ReplyDeleteGreat post, thanks for sharing valuable information, keep more posting. Mern Stack Course in Pune
ReplyDelete