Export Data from IBM DB2 iSeries to SQL Server

Problem

One of our clients has an IBM DB2 for iSeries (“IBM DB2 for i”) database. Connecting using a traditional DB2 ODBC driver does not work for this type of database platform. I need to move some data from the iSeries to a staging database on SQL Server using SSIS, how can I connect?

Solution

In this tip we will provide the steps to install a data source driver and to configure an ODBC connection to the IBM DB2 for i (iSeries). We will also show an example SSIS (SQL Server Integration Services) package that exports data from the iSeries to a SQL Server database.

Driver Installation

In order to connect to the iSeries from SQL Server you have to make sure that an ODBC driver is installed on the server. You can also install it on your development PC if you need to perform ad-hoc data queries or data extracts.

After downloading IBM i Access, start the installation by double-clicking on the cwblaunch.exe file in the driver installation folder:</p

Source Files

Select setup language:

Select language

Accept the terms in the license agreement on the next screen.

Select destination folder for the installation on the screen after that.

Select the primary language:

Select primary language

Choose the custom setup type on the screen below:

Select setup type

Click the “Next” button on the following screen:

Select setup type

Select the Data Access Providers and clear the selection for the “System i Navigator” and the “Data Transfer Base Support”:

Custom setup

Complete the installation by using the default settings on the remaining screens.

Important! Make sure you understand the licensing requirements for the IBM i Access for Windows. For example, ODBC and other data source providers are free, but the “Data Transfer Base Support” requires a separate license. To copy data we only need the ODBC driver, the “Data Transfer Base Support” is not required.

ODBC Data Source

Open the ODBC Data Source Administrator and click “Add” under the “System DSN” tab:

ODBC Select Driver

Select “iSeries Access ODBC Driver” and click “Finish”.

Now we will configure the ODBC connection’s settings for the iSeries database.

Specify the data source name under the “General” tab and enter the host name of your iSeries as “System”:

ODBC Configure Driver - General TAB

Specify the Default Schema or Library under “Server” tab and enable “Override default database” option:

ODBC Configure Driver - Server TAB

Note, that settings may vary depending on your environment. You may need to contact your iSeries administrator for the correct settings. One of the examples (but using the older driver) could be found here.

Enter the package library name under the “Packages” tab:

ODBC Configure Driver - Packages TAB

Click “OK” button to save the new ODBC data source.

Data Export with SSIS Package

We will create the new SSIS project in Visual Studio 2012. You can also create the new project using “SQL Server Business Intelligence Development Studio” or use one of your existing projects.

In Visual Studio’s Solution Explorer create the new project’s Connection Managers (for both – SQL Server and iSeries):

New Project's connection

Select “Connection manager for ODBC connections” to create the new connection to the iSeries database:

Use ODBC Connection Manager

Select the “DB2 DEV” ODBC connection that was created earlier and enter the password under the “Login information”:

ODBC Connection Manager Configuration

Review the new data connection and click “OK” to save it:

ODBC Connection Manager review

To create the SQL Server Connection Manager select the “Connection manager for OLE DB connections”. Enter the server name, credentials (if SQL Server Authentication is used) and a staging database name (the database that will hold the exported data):

OLE DB SQL Server Connection

Click “OK” twice to save the SQL Server Connection Manager.

Now we have two Project Connection Managers:

Project with Connections

Alternatively you can create package level connections. Read more about SSIS connection managers here.

Create the new package under SSIS Packages.

Open the package and drag the “Data Flow Task” from the toolbox to the “Control Flow” area:

Add Data Flow task to the Control Flow

Double click the “Data Flow Task” and drag “ODBC Source” and “OLE DB Destination” from the SSIS Toolbox:

Configure Data Flow task

Double click and configure the “ODBC Source”. Select a table/view name, click “Columns” on the left and click “OK”:

Configure Source Details

Drag the Data Flow arrow from the “ODBC Source” to the “OLE DB Destination”. Double click the destination container and configure the properties.

Create the new table by clicking the “New” button or use existing table by selecting the table name from the drop down list. Click “Mappings” on the left to complete the columns mappings and click “OK” to complete the destination configuration:

Configure Destination Details

Read more tips about SSIS Data Flow Transformations here.

Now the package is ready for execution. Run the package and verify the results:

Run Package

Next Steps

  • Read more tips about SSIS Development.
  • Find out more about other database platforms here.
  • See if you can be useful for your company even if you don’t support other database systems by bringing data to a SQL Server staging database and building reports.

Leave a Reply

Your email address will not be published. Required fields are marked *