Click here to Skip to main content
15,900,110 members
Articles / Programming Languages / SQL
Tip/Trick

Import Data from Excel to SQL Using SSIS 2012 Dynamic Configuration

Rate me:
Please Sign up or sign in to vote.
4.06/5 (8 votes)
25 Nov 2014CPOL2 min read 54.3K   5   5   4
How to import data from Excel to SQL using SSIS 2012 Dynamic Configuration

Package 1: Import Excel Data to Database Table

Step 1: Create Sample Excel data same as below:

Image 1

Step 2: Create folder name “ImportExcel” and copy the SampleData file here.

Image 2

Step 3: Open SQL Server Management Studio and run the below script to create database and its tables.

SQL
create database ImportExcel

Use ImportExcel
Go

create table EMP_A(Id Int,Name Nvarchar(500),Dept varchar(10) default 'IT')
create table EMP_B(Id Int,Name Nvarchar(500),Dept varchar(10) default 'HR')

Step 4: Create SSIS project and name as “ImportExcel”.

Image 3

Step 5: Drag one sequence container and name it as “ImportExcel” as below:

Image 4

Step 6: Drag one Dataflow task to the sequence Container.

Image 5

Step 7: Right click on package and click on variables and click on add variable.

Image 6

Step 8: Since we want to run this package as dynamic... please go to dataflow task properties and make delayvalidation property as “True”.

Image 7

Step 9: Double click on Dataflow task and bring Excel source and make delay validation as “True” (ValidateExternalMetaData=”false”).

Image 8

Step 10: Right click on “Excelsource” and click on Edit.

Image 9

Step 11: Click on new and browse the Excel path and click on OK.

Image 10

Step 12: Select like below and click on ok.

Image 11

Step 13: Now our Source connection is ready and developed.

Image 12

Step 14: We just want to make our ExcelSource Connection as Dynamic.

Right click on “Excel Connection Manger” and click on properties -> Click on Expressions.

Image 13

Step 15: Click on property dropdown and select ExcelFilepath.

Image 14

Step 16: Browse Expression button and select variable as below and click on ok.

Image 15

Image 16

Step 17: We are done with source and now we need to configure Destination as below.

Drag and drop “OLEDB Destination “ and make a connection to source and destination as below.

Image 17

Step 18: Right click on Destination and click on Properties and make “validateExternalMetadata” as False.

Image 18

Step 19: Right click on Destination and click on edit.

Image 19

Image 20

Step 20: We are done with package. Before running the package, please make the below changes as Excel adapter does not support 64bit.

Right click on project and click on properties and select Debugging and make Run64bitRuntime as false.

Image 21

Image 22

Step 21: Save & run the package.

Image 23

Step 22: Check whether data has been populated in database tables or not.

Image 24

Step 23: Next step is we need to create dynamic configuration, to achieve this please follow the below steps:

Click on SSIS Menu->packageConfigurations->EnablePackageConfigurations-> click on Add

Image 25

Step 24: Next->Add XML ConfigurationFile->Browse select path and click on Next.

Image 26

Step 25: And select variables which you want to make as dynamic and click on next->Finish->Close.

Image 27

Step 26: Now, we are able to see file called “ImportExcelProjConfig.dtsconfig”.

Image 28

Step 27: Now, you can change this file for dynamic purpose.

Image 29

For testing, we just change the sample data path and destination table path as below:

SampleData : D:\practice\SSIS\B\SampleData.xlsx
Table : EMP_B

Step 28: Save and run the package to test the results:

Image 30

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionvote of 4 Pin
pinguit26-Nov-14 15:00
pinguit26-Nov-14 15:00 
QuestionGOOD! Pin
Member 1111981626-Nov-14 14:36
Member 1111981626-Nov-14 14:36 
QuestionGood Job Pin
Lolo198626-Nov-14 11:41
professionalLolo198626-Nov-14 11:41 
AnswerRe: Good Job Pin
sudheer mattapally26-Nov-14 21:47
sudheer mattapally26-Nov-14 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.