Problem with Linked Server from SQL to DB2

From: Paul (Paul_at_discussions.microsoft.com)
Date: 10/21/04


Date: Thu, 21 Oct 2004 15:05:04 -0700


I'm trying to setup a linked server from SQL to DB2 UDB (on AIX). We want
to be able to issue SQL statements (SELECT, INSERT, UPDATE, and DELETE) using
the four-part name (i.e. MyLS.DBName.Schema.TableName). I've tried both the
Microsoft provided OLE DB driver for DB2 (DB2OLEDB) and the IBM DB2 OLE DB
Driver (IBMDADB2). Each driver ended up with different results. The SQL
commands to setup both linked servers (one Microsft driver and one IBM
driver) are included at the bottom of this post (with IP, Port, User ID, and
password omitted of course). Also the SELECT commands and their results are
included.

The linked server using the IBM driver allows me to run SELECT queries using
the OPENQUERY method, however not using the 4-part name. The linked server
using the Microsoft driver does not appear to work at all.

I've looked through many newsgroup posts and Microsoft articles, but have
not been able to find a solution. Any help would be greatly appreciated.

Thanks.

Paul

--+++IBM
EXEC sp_addlinkedserver
        @server = 'LS_IBMUsingSP',
        @srvproduct = 'SAMPLE',
        @provider = 'IBMDADB2',
        @datasrc = 'SAMPLE',
        @location = 'xxx.xxx.xxx.xxx:xxxx',
         @provstr = 'Provider=IBMDADB2;Password=xxxxxx;Persist Security
Info=True;User ID=xxxxxx;Data
Source=SAMPLE;Location=xxx.xxx.xxx.xxx:xxxx;Extended Properties=""',
         @catalog = 'SAMPLE'

EXEC sp_addlinkedsrvlogin
        @rmtsrvname = 'LS_IBMUsingSP',
        @useself = false,
        @rmtuser = 'xxxxxx',
        @rmtpassword = 'xxxxxx'

EXEC sp_serveroption
        @server = 'LS_IBMUsingSP',
        @optname = 'data access',
        @optvalue = 'true'

SELECT *
FROM LS_IBMUsingSP.[SAMPLE].DB2TDBM.DEPARTMENT

-- Invalid schema or catalog specified for provider 'IBMDADB2'.
-- OLE DB error trace [Non-interface error: Invalid schema or catalog
specified for the provider.].

SELECT *
FROM OPENQUERY(LS_IBMUsingSP, 'SELECT * FROM DB2TDBM.DEPARTMENT')

-- This works fine.

-----IBM

--+++MICROSOFT
EXEC sp_addlinkedserver
        @server = 'LS_MicrosoftUsingSP',
        @srvproduct = 'SAMPLE',
        @provider = 'DB2OLEDB',
        @datasrc = 'SAMPLE',
        @location = 'xxx.xxx.xxx.xxx:xxxx',
         @provstr = 'Provider=DB2OLEDB;Password=xxxxxx;Persist Security
Info=True;User ID=xxxxxx;Initial Catalog=SAMPLE;Data Source=SAMPLE;Network
Transport Library=TCPIP;Network Address=xxx.xxx.xxx.xxx;Network
Port=xxxx;Package Collection=db2tdbm;Default Schema=db2tdbm;Units of
Work=DUW',
        @catalog = SAMPLE

EXEC sp_addlinkedsrvlogin
        @rmtsrvname = 'LS_MicrosoftUsingSP',
        @useself = false,
        @rmtuser = 'xxxxxx',
        @rmtpassword = 'xxxxxx'

EXEC sp_serveroption
        @server = 'LS_MicrosoftUsingSP',
        @optname = 'data access',
        @optvalue = 'true'

DBCC TRACEON(7300, 3604)

SELECT *
FROM LS_MicrosoftUsingSP.[SAMPLE].DB2TDBM.DEPARTMENT

-- Could not fetch a row from OLE DB provider 'DB2OLEDB'.
-- OLE DB error trace [Non-interface error: OLE DB provider DB2OLEDB
returned DBPROP_STRUCTUREDSTORAGE without DBPROPVAL_OO_BLOB being supported].
-- [OLE/DB provider returned message: One or more errors occurred during
processing of command.]
-- [OLE/DB provider returned message: A SQL error has occurred. Please
consult the documentation for your specific DB2 version for a description of
the associated Native Error and SQL State. SQLSTATE: 51002, SQLCODE: -805]
-- OLE DB error trace [OLE/DB Provider 'DB2OLEDB' IRowset::GetNextRows
returned 0x80040e14].

SELECT *
FROM OPENQUERY(LS_MicrosoftUsingSP, 'SELECT * FROM DB2TDBM.DEPARTMENT')

-- An error occurred while preparing a query for execution against OLE DB
provider 'DB2OLEDB'.
-- OLE DB error trace [Non-interface error: OLE DB provider DB2OLEDB
returned DBPROP_STRUCTUREDSTORAGE without DBPROPVAL_OO_BLOB being supported].
-- [OLE/DB provider returned message: A SQL error has occurred. Please
consult the documentation for your specific DB2 version for a description of
the associated Native Error and SQL State. SQLSTATE: 51002, SQLCODE: -805]
-- OLE DB error trace [OLE/DB Provider 'DB2OLEDB' ICommandPrepare::Prepare
returned 0x80040e14].
-----MICROSOFT



Relevant Pages

  • Problem with Linked Server from SQL to DB2
    ... I'm trying to setup a linked server from SQL to DB2 UDB. ... Microsoft provided OLE DB driver for DB2 and the IBM DB2 OLE DB ... -- Invalid schema or catalog specified for provider 'IBMDADB2'. ...
    (microsoft.public.data.oledb)
  • Re: Current System as Global Variable
    ... I have changed the OLE DB Provider and have tested on the SQL Server ... and then I clicked the parameters tab it ...
    (microsoft.public.sqlserver.dts)
  • Re: XP_CmdShell and OLE provider
    ... If I execute the below line in SQL Query Analyzer, ... I am not finding the one I installed: "Microsoft OLE DB Provider for Visual ...
    (borland.public.delphi.database.ado)
  • Re: XP_CmdShell and OLE provider
    ... If I execute the below line in SQL Query Analyzer, ... I am not finding the one I installed: "Microsoft OLE DB Provider for Visual ... Does anyone know how we can make SQL Server aware of the newly installed OLE ...
    (microsoft.public.data.ado)
  • Re: Access db2 via .Net
    ... > I need to access a db2 database that sits on the Z/OS. ... > I read some where that the .Net ole db provider calls the IBM Ole Db ... I haven't seen the separate download of the ...
    (microsoft.public.dotnet.framework.adonet)

Quantcast