Note: Power Query is known as Get & Transform in Excel 2016. Information provided here applies to both. To learn more, see Get & Transform in Excel 2016. Before you can connect to an IBM DB2 database, you need the IBM DB2 Data Server Driver installed on your computer (minimum requirement is the IBM Data Server Driver Package (DS Driver)). Select the driver that matches your Power Query installation (32-bit or 64-bit). Warning: There are known issues reported by IBM installing the IBM DB2 Data Server Driver on Windows 8. If you are using Windows 8 and want to connect to IBM DB2 using Power Query,
you need to follow additional installation steps. For more information about the IBM DB2 Data Server Driver on Windows 8, see http://www-01.ibm.com/support/docview.wss?uid=swg21618434. To connect to an IBM DB2 database: In the POWER
QUERY ribbon tab, click From Database > From IBM DB2 Database. In the IBM DB2 Database dialog box, in Server Name specify the IBM DB2 Database Server to connect to. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database
Query. Click OK. If the IBM DB2 server requires database user credentials: In the Access a Database dialog box, enter your username and password. Click Connect. Import data from external data sources Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. IBM Db2 database
In this articleSummary
Note Some capabilities may be present in one product but not others due to deployment schedules and host-specific capabilities. PrerequisitesBy default, the IBM Db2 database connector uses the Microsoft driver to connect to your data. If you choose to use the IBM driver in the advanced options in Power Query Desktop, you must first install the IBM Db2 driver for .NET on the machine used to connect to the data. The name of this driver changes from time to time, so be sure to install the IBM Db2 driver that works with .NET. For instructions on how to download, install, and configure the IBM Db2 driver for .NET, go to Download initial Version 11.5 clients and drivers. More information: Driver limitations, Ensure the IBM Db2 driver is installed Capabilities Supported
Connect to an IBM Db2 database from Power Query DesktopTo make the connection, take the following steps:
Connect to an IBM Db2 database from Power Query OnlineTo make the connection, take the following steps:
Connect using advanced optionsPower Query provides a set of advanced options that you can add to your query if needed. The following table lists all of the advanced options you can set in Power Query.
Once you've selected the advanced options you require, select OK in Power Query Desktop or Next in Power Query Online to connect to your IBM Db2 database. Issues and limitationsDriver limitationsThe Microsoft driver is the same one used in Microsoft Host Integration Server, called the "ADO.NET Provider for DB2". The IBM driver is the IBM Db/2 driver that works with .NET. The name of this driver changes from time to time, so be sure it's the one that works with .NET, which is different from the IBM Db2 drivers that work with OLE/DB, ODBC, or JDBC. You can choose to use either the Microsoft driver (default) or the IBM driver if you're using Power Query Desktop. Currently, Power Query Online only uses the Microsoft driver. Each driver has its limitations.
Microsoft provides support for the Microsoft driver, but not for the IBM driver. However, if your IT department already has it set up and configured on your machines, your IT department should know how to troubleshoot the IBM driver. Native queries not supported in DirectQueryWhen you select DirectQuery as the data connectivity mode in Power Query Desktop, the SQL statement text box in the advanced options is disabled. It's disabled because the Power Query IBM Db2 connector doesn’t currently support query push down on top of a native database query. TroubleshootingEnsure the IBM Db2 driver is installedIf you choose to use the IBM Db2 driver for Power Query Desktop, you first have to download, install, and configure the driver on your machine. To ensure the IBM Db2 driver has been installed:
If this name is in the InvariantName column, the IBM Db2 driver has been installed and configured correctly. SQLCODE -805 and SQLCODE -551 error codesWhen attempting to connect to an IBM Db2 database, you may sometimes come across the common error SQLCODE -805, which indicates the package isn't found in the Typically, SQLCODE -805 is followed by SQLCODE -551, but you'll see only the second exception. In reality, the problem is the same. You lack the authority to bind the package to either Typically, most IBM Db2 administrators don't provide bind package authority to end users—especially in an IBM z/OS (mainframe) or IBM i (AS/400) environment. Db2 on Linux, Unix, or Windows is different in that user accounts have bind privileges by default, which create the MSCS001 (Cursor Stability) package in the user’s own collection (name = user login name). If you don't have bind package privileges, you'll need to ask your Db2 administrator for package binding authority. With this package binding authority, connect to the database and fetch data, which will auto-create the package. Afterwards, the administrator can revoke the packaging binding authority. Also, afterwards, the administrator can "bind copy" the package to other collections—to increase concurrency, to better match your internal standards for where packages are bound, and so on. When connecting to IBM Db2 for z/OS, the Db2 administrator can do the following steps.
When connecting to IBM Db2 for Linux, Unix, or Windows, the Db2 administrator can do the following steps.
When connecting to IBM Db2 for i, the Db2 administrator can do the following steps.
SQLCODE -360 error codeWhen attempting to connect to the IBM Db2 database, you may come across the following error:
This error message indicates that you didn’t put the right value in for the name of the database. SQLCODE -1336 error code
Double check the name, and confirm that the host is reachable. For example, use ping in a command prompt to attempt to reach the server and ensure the IP address is correct, or use telnet to communicate with the server. SQLCODE -1037 error code
The port is specified at the end of the server name, separated by a colon. If omitted, the default value of 50000 is used. To find the port Db2 is using for Linux, Unix, and Windows, run this command:
Look in the output for an entry for SVCENAME (and SSL_SVCENAME for TLS encrypted connections). If this value is a number, that’s the port. Otherwise cross reference the value with the system's "services" table. You can usually find this at /etc/services, or at c:\windows\system32\drivers\etc\services for Windows. The following screenshot shows the output of this command in Linux/Unix. The following screenshot shows the output of this command in Windows. Determine database nameTo determine the database name to use:
Determine port numberThe Microsoft driver connects to the database using the Distributed Relational Database Architecture (DRDA) protocol. The default port for DRDA is port 446. Try this value first. To find for certain what port the DRDA service is running on:
More information
FeedbackSubmit and view feedback for How do I query a Db2 in Excel?Creating a query of Db2 data
In Microsoft Excel, go to the Data tab > Get External Data > From Other Sources > From Data Connection Wizard. Click Other/Advanced and then click Next. Select the Db2 OLE driver that you previously installed and then click Next. Select Direct server connection.
How do I export data from IBM Db2 to Excel?Option 2: Using the IBM Data Studio. Connect to the database you want to export.. Select the table you want to export.. Open context menu by right-clicking on the table.. Select the option Unload -> With Export Utility to open the integrated export tool.. Select JDBC as Run method.. Pick your path and file name for the csv file.. What tool is used to connect Db2?Connecting to a database using the Db2 Command Line Plus (CLP) tool.
How do I enable ODBC in Excel?Case Study. Select Start, Settings, Control Panel, Administrative Tools, Data Sources (ODBC). ... . Navigate to the System DSN tab and click Add to open the Create New Data Source dialog box.. Select Microsoft Excel Driver as the driver for which you want to set up the data source. ... . Specify a name for the data source.. |