Import Data from Multiple Excel Files\Folders using SSIS/ETL

Intro: - This article is about SSIS, which is very useful tool provided by Microsoft, so let’s talk about a problem which we (database de...

Intro: - This article is about SSIS, which is very useful tool provided by Microsoft, so let’s talk about a problem which we (database developers) face may times, and talk about its solution.
Many times we have got data in excel files, on daily bases, or got multiple files at a time having same schema, and we want to import these all in our database. So importing data from these files one by one is very time consuming and boring task.
 Best solution of this problem is ETL, you can create a SSIS package for import multiple excel file data.
Here we will discuss how to create SSIS package.
So let’s start.



Step 1: Create new integration Service Project as “Test”, here I am using visual studio 2010


Step 2: Right click on package and rename it as “ImportMultipleExcelFilesData.dtsx”

Step 3: Now create a folder with sub folder and multiple excel files,

Ex:- E:\Vikas Ahlawat\SampleSSIS\ExcelFiles


But make sure all Excel files have identical schema/format assuming all Excel files above contain data in worksheet “Sheet1”





Excel files Schema:-
Make sure that all three excel file should same schema like below
File1.xlsx’s Schema


Step 5: Right Click on Control Flow Window, and then click on Variables


Now click on Add Variable icon and then add a variable with name “FileName” of string type.



Step 6: Drag and drop foreach-loop container, and Inside it drag and drop “Data flow task”


Step 7: Right-click on the Foreach Loop container and select Edit. Then, Click on Collection “Collection” tab. Assign folder path and file type as shown below


Then go to “Variable Mappings“ tab and map variable created above like below


Step 8: Now double click on “Data Flow Task”
Drag one “Excel Source” task, double click on this to get “Excel Source Editor” Window
Now choose new and new window will open, now browse to your first excel file that is
E:\Vikas Ahlawat\SampleSSIS\ExcelFiles\File1.xlsx
Under “Name of the Excel Sheet” on “Excel Source Editor”, choose Sheet1$


Step 9: Now drag “OLE DB Destination” task, connect “Excel Source” to “OLE DB Destination”
Point this connection to your database and create new table or use an existing table

Step 10: Now go to "Data Flow task"s property and set DelayValidation property value as True. Otherwise it will insert File1 data three times.

Step 11: Now execute your package, and check your table you will find all three file data in your table.

Thanks



Related

SSIS 7898843112472531268

Post a comment

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item