I am trying to create a linked server from MSSQL 2014  to DB2 11.1  I am able to create one linked server and get it to work with one DB.  I have not been able to figure out how to add additional catalogs(DB's).  Is it possible to use just one linked server for multiple databases.

Views: 30

Reply to This

Replies to This Discussion

Hello Mike,

I tried to connect to db2 11.1 from sqlserver 2016 using IBMOLEDB driver. It works partially. i.e I can get table column headers but having issues in getting data.

I did it through below TSQL:

Create a ODBC system DSN to connect to a db2 database and test the connection. My DSN name is "test"

My db2 11.1 database is also named "test".

Database 1 entry:
 Database alias                       = TEST
 Database name                        = TEST
 Local database directory             = C:
 Database release level               = 15.00

[CLI_ODBC>TEST]
DataSourceName=test
DataSourceType=User
DBALIAS=TEST
PWD=xxx
UID=xxx
ODBCParameters=Yes

USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'TEST3', @srvproduct=N'db2', @provider=N'IBMOLEDB', @datasrc=N'test'
GO
USE [master]
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'TEST3', @locallogin = NULL , @useself = N'False', @rmtuser = N'loginID', @rmtpassword = N'password
GO
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'TEST3', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'IBMOLEDB.test', N'AllowInProcess', 0
GO

EXEC sp_linkedservers;
SRV_NAME  SRV_PROVIDERNAME SRV_PRODUCT SRV_DATASOURCE SRV_PROVIDERSTRING SRV_LOCATION SRV_CAT
TEST3   IBMOLEDB   db2   test NULL NULL NULL

select * from OPENQUERY(TEST3,'SELECT * FROM SYSCAT.TABLES');
TABSCHEMA TABNAME
It didn't bring the data, only headers with the following message. Hope more research will get the data.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "IBMOLEDB" for linked server "TEST3" reported an error. Access denied.
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider "IBMOLEDB" for linked server "TEST3".
If you get more luck, let me know.
Rgds,
Thiru Swamy

Thiru,

I appreciate your feedback.  I am new to DB2 and still learning but i would verify the permissions you have set for your linked server account as it looks like maybe you don't have them set properly.

Thanks,

Michael Jett

RSS

Bringing Db2 enthusiasts together virtually. Expert or novice, distributed or mainframe, this is the place for everything DB2.

Forum

MSSQL linked server attaching to DB2 LUW

Started by Mike Jett in Application Development and DB2. Last reply by Mike Jett 12 hours ago. 2 Replies

I am trying to create a linked server from MSSQL 2014  to DB2 11.1  I am able to create one linked server and get it to work with one DB.  I have not been able to figure out how to add additional catalogs(DB's).  Is it possible to use just one…Continue

Tags: server, linked

Db2 12 Migration Planning & Customer Experiences - Part 1

Started by Sandy Flippen in What's hot ? Sep 12. 0 Replies

Register Now! NEXT CONTENT! Upcoming double webcast Db2 12 Migration Planning and customer experiences. Live Q &A session! PART 1 http://ibm.biz/BdzKxv 24th Sept 11:00 AM EST PART 2…Continue

PlanetDB2.com [Latest Blogs from the Biggest Names in DB2]

© 2019   Created by Surekha Parekh.   Powered by

Badges  |  Report an Issue  |  Terms of Service