Problem : How to query an alias in a DB2 linked server from SQL Server 2008

Problem : How to query an alias in a DB2 linked server from SQL Server 2008

Hello everyone,

I created an table alias in DB2 and created a linked DB2 server in SQL Server 2008 with the IBMDASQL provider. Now I need to query the alias from SQL Server, but I receive the following error message:

Msg 7357, Level 16, State 2, Line 3
Cannot process the object “S650a370.PROBIS03.NAW_ALIAS”. The OLE DB provider “IBMDASQL” for linked server “DB2SQL” indicates that either the object has no columns or the current user does not have permissions on that object.

However, the object has multiple columns and I have Owner permissions on that object.

I tried to create the linked server with the IBMDA400 and IBMDARLA providers without any success. I also tried to query some other tables and that works fine, but when i try to query an alias i get an error message. Unfortunately I need to use the alias, because the underlying table contains multiple members and I can’t query a table member directly with an SQL command.

Any ideas? Thanks in advance.


Solution: How to query an alias in a DB2 linked server from SQL Server 2008

Hi,

I think your problem relates to using the IBM drivers in creating your linked servers.
While our experience is MS SQL2000 based we always had to create the linked servers to an AS400 DB2 databases by specifying the MS ODBC drivers and creating an ODBC connection to the AS400

Please note one linked server will give access to all libraries on the AS400 so you don’t need a seperate linked server for each library you want access to, we only discovered this later.

So we set linked server up having first created an ODBC connection to the AS400 on the MS SQL server

we only specified on the first tab for the linked server….

Product Name (The hostname of our AS400)
Data Source (Name of the ODBC datasource)

On the security tab we added a user / password that was valid with all object authority of the AS400

We then used the following openquery syntacx to create linked server views on the MS SQL server

CREATE VIEW dbo.vw_LS_xxxxxxxxx
AS
SELECT     *
FROM         OPENQUERY(Linked_Server_Name,
‘select * from AS400_Machine_Name.LibraryName.Table_Name ‘)
Rowset_1

Hope this helps.