Category Archives: SSIS

A recent Windows 2012 OS roll up patch causes the execution of any SSIS package to fail under the following conditions:
1. The package is using Microsoft.Jet.OLEDB.4.0
2. The Package is executed from a SQL job.
3. The OS is Windows 2012 on which the SQL is installed.

Snapshot of the error message:

MS has acknowledged the issue. Below link with details and workaround.

Like this:

In this article we will go through how we can extract images from a table in SQL Server and copy it on a folder. To achieve this we need to use SQL Server Integration Service. Let’s go over the process step by step.

Step 1: Create a new SSIS project in BIDS

Step 2: Drag and drop the Data Flow Task from the SSIS Toolbox to the design surface

Step 3: Go to the Data Flow tab. Drag and Drop the following on the design surface.

Step 4: Right click on the connection manager area and create a new OLEDB connection. We will create a connection for the AdventureWorks2012 database and the Production.Photo table.

Share this:

Like this:

In my previous article I wrote about the For loop Container. In this article I will show how we can implement the Foreach loop container with a demo. The Foreach loop container is the third container amongst the three containers in SSIS.

The Foreach loop container can be used to loop through a set of enumerated objects like files in a folder or rows in a table. We can add different control flow tasks within the container for each enumerator or a DataFlow task to process data related to each item. Let us now implement this container with a small demo.

Implementing Foreach Loop Container

Objective: To copy files from one folder to another folder.

Step 1: We will be using the package we created in my article. Drag and drop a Foreach loop container in the design UI surface -> Drag and drop a File system task inside the container.Step 2 : Create a variable as shown below with the depicted data type and valueStep 3: create 2 folders named ‘Source’ and ‘destination’ respectively. In the source folder create two files named file1.txt and file2.txtStep 4: Right click -> Choose Edit on the Foreach loop container and fill up the following as depicted below. Click on OK.Step 5: Right Click on the File System task -> On DestinationConnection -> Choose the usage type as ‘Existing Folder’ -> Choose the path of the destination folder -> click on ok.Step 6: Set the rest of the fields as below -> Click on OK.Now we are ready to test out solution. Press F5 and the 2 files should be in the destination folder.Bingo!!!! The files has been copied to the destination folder. I hope this article was useful in understanding the Foreach loop and its understanding.

Share this:

Like this:

In my previous article we discussed about the Sequence container. In this article we will implement the For loop container. The objective of this container is that it will iterate through all the tasks inside until the condition is satisfied. For every iteration the For Loop container evaluates the condition that is specified and repeats the process until the condition stands false.

The For loop container has 3 expressions that determines the number of executions that container would undergo. let us understand these expressions briefly.

InitExpression:

This is an optional expression in the For loop container. It is evaluated before any process is started inside the loop. The major use of this expression is to set an intial value as the name indicates.

EvalExpression:

The second expression when the loop starts. It is also evaluated before any process is executed inside the container, and then again evaluated at the beginning of each loop. This determines if the loop continues or ends.
If the condition stands TRUE, the process is executed again. If the condition stands FALSE, the loop ends.

AssignExpression:

The is the 3rd condition used in the For Loop. It is used to change the value of the variable used in the EvalExpression. This expression is evaluated for each pass through the loop as well, but at the end of the workflow. This condition is optional.

Implementation of the for loop Container

Lets implement the For loop container. I will be using the project I created in the my article.

Step 1: Open the project in BIDS -> Add a Execute SQL task on the UI design surface. Insert the following script in the task

Step 3: Click on the variable tab -> create a variable called counter with data type as Int64 or Int32.Step 4: Right Click inside the For loop container and click on edit. Fill in the expressions as depicted in the pic below -> Click on OK.Step 5: Press F5 and make sure the execution succeeds
What we observe in the database is that the table has been created with 10 rows inserted in the table.
In this is article I have tried to implement the For Loop container in a very simplified manner. I hope I was able to do that.

Share this:

Like this:

In this article we will understand how we can use a Sequence Container with a demo. In my previous article I wrote about Control Flow Objects in SSIS.

Sequence Container and its benefits

Sequence container groups related tasks in a package and helps in understanding the complexity of a package in a simpler way. The objective of the Sequence container is to have multiple separate control flows grouped together in the package.

Some of the benefits of the package are as below:
1) Helps in debugging.
2) If a package has multiple tasks then it is easier to group the tasks in Sequence Containers and we can collapse and expand this container for usability.
3) We can set the property of entire container rather than setting the property of individual tasks.
4) We can set the flexibility of completion of the process in the container to a transaction level i.e in case of an error the entire process can be rolled back or partial success can be achieved.

Implementing Sequence Container

Now we will implement the sequence container with a demo. In the first example we will not use TransactionOption but in the second example we will. Let us begin. We will be using the project we created in my article.

Step 1: Open the SSIS Project -> Click on the package MyPackage.dtsx -> Drag and drop a Sequence Container from the toolbox on the design surface -> Drag three Execute SQL Task objects in the Sequence ContainerStep 2: Rename the 1st Task as Create Table. Rename the second task as Insert Values. Rename the 3rd Task as Update Values -> Drag the constraint from the 1st task onto the Insert Values Task and then drag the constraint from the Insert Values Task onto the Update Values Task. The structure should look like belowStep 3: Right click on the Create Table Task -> Click Edit -> Change the connection to AdventureWorks2008 -> Click on the SQLStatement and insert the following code -> Click on OK.

Step 2: Select the Sequence Container -> On the properties tab -> TransactionOption -> Select Not Supported.Step 3: Not lets drop the table from the database so that the create table does not error out.Step 4: Press F5 and run the package and lets observe what happens

Observation: What we observe is that the package has failed(red) and the update values Task has also failed(red). Let now have a look at the database and see what impact has this package made.What we observe is that create table and insert values task has succeeded but the update values task has failed. So this what NotSupporteddoes. It does not do a full roll back.

Example 2:

Now we will change the TransactionOptionto Requiredand observe what happens
Step 1 : Drop the table from the database
Step 2 : Change the TransactionOption to RequiredStep 3: Press F5.Observation:

The Package fails but lets verify what has happened at the database level by running a select on the table.
The entire process has been rolled back. The table structure does not exist even though the create table had succeeded. So this is what The Required option does. In case of an error it rolls back the entire package.

In this article I have tried to explain the use of the sequence container in a simplified manner. I hope i was able to do that.

So what is Control Flow?

Control Flow is the enginewhich manages the workflowof the tasks created coupled with the control flow containers and constraints. SSIS provides a Design UI which displays a workspace where we can configure different control flow objects.

SSIS provides threetypes of control flow objects
1) Tasks– Tasks are objects that perform specific work
2) Containers– Containers help group different tasks
3) Constraints– Constraints help connecting different tasks and containers. Its also helps to define the order of execution of different tasks.

A package must contain at least one task that performs a certain operation. When multiple tasks are configured, then a container can be used to group them together.

Container

SSIS provides three types of Containers. Here is a brief description about the three Containers. We will deep dive into the Containers later.

1) Sequence Container : This allows us to group multiple tasks together. The benefits of this feature is that we can control the entire group rather that managing each task separately. It also means we can run different tasks sequentially or parallel. The entire group can collapsed or expanded. The Sequence container is the 3rd container in the toolbox2) For Loop Container : This provides the same functionality as the sequence container but also lets you run tasks multiple times based on the condition provided. The For Loop is the 1st tool in the tool box3) Foreach Loop Container : This allows looping but instead of a condition the looping happens over objects such as files and folders or tables in a database.

Implementation of Control Flow Task

We will now implement the above by creating and editing a control flow task and executing the package within the SSIS environment. We will be using the same project we created in our previous article for this demo.

Step 1: Open the Project using BIDS -> Select Mypackage.dtsx -> Click on the Toolbox -> Drag and Drop the Execute SQL Task on the Designer Surface. Rename the task as Update Table
Step 2: Right Click on the Task– > Click on Edit -> Change the Connectionto AdventureWorks-> Click on the SQLStatementand insert the below query – > Click on OK.Query:

Step 3: click Start Debugging on the Standard toolbar -> If the execution is correct then the task would be green.Step 4: Click on the Progress tab to view the execution details of the task. -> Stop the execution by clciking on the stop debugging button – > Save the project.

The objective of this article was an introduction to the concept of Control Flow and Taskswith a small demo. I hope I was able to do that. In my next article I will write about Container with a broader perspective.

Share this:

Like this:

In this article we will see how we can create a SSIS project via visual studio and then create a packageand linking the packages to data sources along with connections. For this demo i will be using SQL Server 2008. The steps remain same for SQL Server 2008 R2 and SQL Server 2012.

creating a SSIS project…

Step 1: Open SQL Server Business Intelligence Development Studio(BIDS). Go to File -> New -> Project

Step 2 : ON the new Project dialog box choose Integration Services Project. Give the Project a name and location as shown below. Click on OK. The Project will appear on the Solution explorer. By default a package is already created named Package.dtsx

Step 3: let us rename this package as MyPackage1. Right click on the Package and select rename. Change the name to MyPackage.dtsx. Click Yes on the confirmation dialog box.
Step 4: We will create two more packages named DC.dtsx and DP.dtsx. Right click on SSIS package on solution explorer and click on New SSIS Package. A package would be automatically added with default name Package(n).dtsx. We will rename the package as DC.dtsx. Repeat the same steps and create another package named DP.dtsx. Click on save all button to save all the changes made.So this is how we will create a SSIS project with packages. In the next section we will create data sources for the project.

creating data sources..

Step 1: Open the Project in BIDS. Right click on Data Sources and select New Data Sources. On the Data source wizard click on new and select a server name and database name. In this case we will choose AdventureWorks as our database.Step 2: Click on OK. Click Next and click on Finish. The new data source will now appear under Data Sources In the next section we will create new package connections from the Data Sources we created.

Creating Connections

Step1 : Click any one of the packages. Right Click on the connection managers window and select New Connection from Data Source. Select the Data source we created name AdventureWorks. Click on OK.The new connection connection will now appear in the connection managers window for the package. We need to create the same for the rest of the two packages.