Problem:
Sometime we have requirement to execute .sql files in SSIS. Let's assume that we have some .sql files in one folder those contain different DDL Statements, DML( update, delete) statements.We want to loop through this folder and execute the code which is stored in each file.
Solution:
Step 1:
First of all we have to use Foreach loop so we can loop through these files. Configure you Foreach loop as show in figure below.
Step 2:
Drag Execute sql task and then configure as shown in Figure below. As we are using the .sql file to run , so instead of direct input we used file connection and then made connection to one of the .sql file.
Step 3:
As we need to loop through the files in folder and run each of the .sql file.We will be using expression on connection manager for file. Each time the foreach loop will pick one file and then connection will be updated and .sql will be executed.
Step 4:
Execute your package.
Sometime we have requirement to execute .sql files in SSIS. Let's assume that we have some .sql files in one folder those contain different DDL Statements, DML( update, delete) statements.We want to loop through this folder and execute the code which is stored in each file.
Solution:
Step 1:
First of all we have to use Foreach loop so we can loop through these files. Configure you Foreach loop as show in figure below.
Step 2:
Drag Execute sql task and then configure as shown in Figure below. As we are using the .sql file to run , so instead of direct input we used file connection and then made connection to one of the .sql file.
Step 3:
As we need to loop through the files in folder and run each of the .sql file.We will be using expression on connection manager for file. Each time the foreach loop will pick one file and then connection will be updated and .sql will be executed.
Step 4:
Execute your package.