Friday, March 9, 2012

Reference Linked Server From Linked Server

Hello all, hoping someone can help.
usual info: windows 2003,sql server 2005 32bit and 64bit
ServerA has a linked server defined that points to ServerB.
ServerC has a linked server defined that points to ServerA.
Is it possible to have a query execute on ServerC that will reference
ServerB through the linked ServerA?
example:
execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
Note:
I understand that I can use openquery:
Select * from openquery(ServerA,'Select * from
ServerB.database.dbo.table')
But because I need to use openquery in the query executed on ServerB
it will get ugly.
Example:
Select * from openquery(ServerA,'Select * From openquery(ServerB,
''Select * from database.dbo.table''')
You may be wondering why I don't just create linked server on ServerC
that references ServerB directly. Let me explain:
ServerC is 64bit SQL Server2005
ServerA is 32bit SQL Server2005
ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
ServerA uses the oledb provider for ODBC datasources to connect to
ServerB. Intersystems does not have an oledb driver. And Microsoft
does not support the oledb provider for odbc datasourceS on 64 bit sql
server.
Any and all ideas are welcome!
Jay
I don't believe this is possible using T-SQL without OPENQUERY or similar.
Would creating views on ServerA that refer to ServerB help? I can't say I
particularly like this approach, but it may be an option.
Stored procedures would be a more fitting approach to take if your querying
is not ad-hoc.
"Jay" <JasonPirtle@.gmail.com> wrote in message
news:8325615c-a36b-4722-9974-a9b58d4756c6@.i12g2000prf.googlegroups.com...
> Hello all, hoping someone can help.
> usual info: windows 2003,sql server 2005 32bit and 64bit
> ServerA has a linked server defined that points to ServerB.
> ServerC has a linked server defined that points to ServerA.
> Is it possible to have a query execute on ServerC that will reference
> ServerB through the linked ServerA?
> example:
> execute on ServerC: Select * from ServerA.ServerB.database.dbo.table
> Note:
> I understand that I can use openquery:
> Select * from openquery(ServerA,'Select * from
> ServerB.database.dbo.table')
> But because I need to use openquery in the query executed on ServerB
> it will get ugly.
> Example:
> Select * from openquery(ServerA,'Select * From openquery(ServerB,
> ''Select * from database.dbo.table''')
> You may be wondering why I don't just create linked server on ServerC
> that references ServerB directly. Let me explain:
> ServerC is 64bit SQL Server2005
> ServerA is 32bit SQL Server2005
> ServerB is 32bit Intersytems Cache Database (ODBC Driver ONLY!)
> ServerA uses the oledb provider for ODBC datasources to connect to
> ServerB. Intersystems does not have an oledb driver. And Microsoft
> does not support the oledb provider for odbc datasourceS on 64 bit sql
> server.
> Any and all ideas are welcome!
> Jay
>

No comments:

Post a Comment