Quantcast
Channel: Welcome To TechBrothersIT
Viewing all articles
Browse latest Browse all 1876

SSIS - [ Read Excel Cell Value In SSIS ( Execute SQL Task) ]

$
0
0

Scenario : 

We have an excel file with Sheet1. We need to get the CreatedBy value that exists in C3 Cell. After reading this information we can use against our validation table to find out if it matches with our requirement so we can proceed with loading Or we can read this information and insert into our Audit table for our record. In short we will be learning how to read a Cell value from Excel in SSIS.

Our input file look like this

Solution : 

We will be using Execute SQL Task in SSIS Package to perform this and Script task to display the value.

Step 1: 
Lets create a variable with name VarCreatedBy as shown below

Step 2:
Place Execute SQL Task on Control Flow Pane and Configure as shown below. Double Click on Execute SQL Task and then Choose Excel in ConnectionType and Click next to Connection that will lead to Source File.

Step 3:
Write Query as shown below and map the Result Set to VarCreatedBy. As you can see in query even I am reading C3 , I did not use C3:C3. we have to provide the range C3:C4 ( means read C3 cell value).


Map the variable


Step 4: 
Lets check the value of VarCreatedBy variable by using Script task

Write the highlighted code as shown below in Script task to display the value at run time.


Final Output :
Lets run the Package and see the final output. As we can see it read the Cell value (C3) and displayed



Viewing all articles
Browse latest Browse all 1876

Trending Articles