views:

375

answers:

2

I have a WebTrends ODBC source on server1 and a SQL Server 2005 on server2. I want to connect to this ODBC from SQL Server on server2. So far, I managed to connect to this ODBC from SQL Server which is on same server, using following definition for linked server:

EXEC sp_addlinkedserver 
@server = N'WT_ODBC', 
@provider=N'MSDASQL', 
@datasrc=N'WT_ODBC_test'

EXEC sp_addlinkedsrvlogin 
@rmtsrvname=N'WT_ODBC',
@useself=N'False',
@locallogin=N'sa',
@rmtuser=N'administrator',
@rmtpassword='########'

I can query this linked server like this:

SELECT *
FROM OPENQUERY(WT_ODBC, 'SELECT * FROM CompleteViewV85.DownloadedFiles');

BTW, I can't query it with four-part name like this:

SELECT *
FROM WT_ODBC.[Complete View V8.5].CompleteViewV85.DownloadedFiles

I receive the following error:

Invalid use of schema or catalog for OLE DB provider "MSDASQL" for linked server   
"WT_ODBC". A four-part name was supplied, but the provider does not expose the  
necessary   interfaces to use a catalog or schema.

..and I verified that option "Level zero only" is not checked. But that is not so problematic, since the first query works.

My problem is - how to connect to this ODBC but from another server? I went on server2, and there in SQL Server I've created the following linked server:

EXEC sp_addlinkedserver 
@server = N'WT_ODBC', 
@srvproduct=N'Microsoft OLE DB Provider for ODBC', 
@provider=N'MSDASQL', 
@datasrc=N'WT_ODBC_test',
@location=N'10.254.251.20'

EXEC sp_addlinkedsrvlogin 
@rmtsrvname=N'WT_ODBC',
@useself=N'False',
@locallogin=N'sa',
@rmtuser=N'administrator',
@rmtpassword='########'

..where I placed the IP address of server1 as @location parameter. Linked server that is created this way can't connect to ODBC on server1. When I try to run the same query that works on server1, I get the following error:

Cannot get the column information from OLE DB provider "MSDASQL" for linked server  
"WT_ODBC".

Help? Someone? Please? :)

Thanks in advance.

A: 

Does it work from ODBC sources in windows, when you test connection? In Administrative Tools\Data Sources (ODBC)

BTW, OPENQUERY is a good way to get data over from "unusual" (for the lack of better word) sources, because the query is pass-through. The query command is sent over to the remote server, executed over there and only results are returned back.

If you do not use open query, it depends on optimizer. If remote server is SQL server, DB2, Oracle, the optimizer will figure it out. If it is something unusual, it may decide to start moving all table data over and then start column and row filtering on local machine -- way slower.

Damir Sudarevic
Yes, ODBC source is ok, and Linked Server based on it works fine, as long as they are both on same physical machine. I'm trying to get it to work from remote server. There is not much examples of Linked Servers with this problem. Most of them just point to a file and they just state the correct path. I'm not sure whether I'm using @location param correctly, or maybe it is a login issue. Anyway, thanks for the OPENQUERY tip.
Dejan
Maybe the real question here is - can you even directly access an ODBC that is on a remote server?
Dejan
YES, make it work from the "ODBC Data Source Administrator" first.
Damir Sudarevic
Ok, so if I understood correctly, in order to reach ODBC on server1, I have to create new ODBC on server2 which will target the first one. If this is the case, then I'm stuck, because I can't create ODBC on server2. ODBC on server1 is special type of ODBC provided by WebTrends and it can be installed only on that server, where WebTrends app is.
Dejan
Yes, the ODBC has to be installed on the "client" machine. It is very unusual that an ODBC driver is "locked" to the DB machine.
Damir Sudarevic
A: 

I'd say that don't use @location parameter, but instead configure your WT_ODBC_test ODBC data source properly. You need to configure it on server2 of course.

Arvo