简体   繁体   English

直接从链接服务器访问链接服务器

[英]Access linked server from linked server directly

I have two SQL Server instances:我有两个 SQL Server 实例:

  • SQLSERVER64 SQLSERVER64
  • SQLSERVER32 SQLSERVER32

In SQLSERVER32 , I have a linked server to a Paradox database called ParadoxDBLinkedServer .SQLSERVER32 ,我有一个连接到名为ParadoxDBLinkedServer的 Paradox 数据库的链接服务器。

To access some of the Paradox tables in the server I just execute the following statement:要访问服务器中的一些 Paradox 表,我只需执行以下语句:

SELECT * 
FROM [ParadoxDBLinkedServer]...Clients

Then, I need to access to these objects from the SQLSERVER64 instance.然后,我需要从SQLSERVER64实例访问这些对象。 In order to do so, I created a linked server called [ .\\SQLSERVER32 ] in this instance pointing to SQLSERVER32 .为此,我在此实例中创建了一个名为 [ .\\SQLSERVER32 ] 的链接服务器,指向SQLSERVER32

What I'm trying to do now is to access directly the ParadoxDBLinkedServer objects from the SQLSERVER64 instance.我现在要做的是从SQLSERVER64实例直接访问ParadoxDBLinkedServer对象。 I mean, accessing a linked server from another linked server.我的意思是,从另一个链接服务器访问链接服务器。

The query I´m trying to run is the following one:我正在尝试运行的查询如下:

SELECT * 
FROM [.\SQLSERVER32].[ParadoxDBLinkedServer ]...Clients

But I get this error:但我收到此错误:

The number name '.\\SQLSERVER32.ParadoxDBLinkedServer ...Clients' contains more than the maximum number of prefixes.数字名称 '.\\SQLSERVER32.ParadoxDBLinkedServer ...Clients' 包含的前缀数超过了最大数量。 The maximum is 3.最大值为 3。

Is there any way to perform an access like this?有没有办法执行这样的访问? What am I missing here?我在这里缺少什么?

I'm trying to avoid creating a View for each table of the ParadoxDBLinkedServer in the SQLSERVER32 instance to reduce overhead.我试图避免在SQLSERVER32实例中为ParadoxDBLinkedServer每个表创建一个视图以减少开销。

This is late, but hopefully can be helpful to someone else who comes to this post later.这已经很晚了,但希望可以对稍后访问此帖子的其他人有所帮助。 If you can use openquery then something like this should work:如果您可以使用openquery那么这样的事情应该可以工作:

SELECT * FROM OPENQUERY([.\SQLSERVER32], 'SELECT * FROM   OPENQUERY([ParadoxDBLinkedServer ],''SELECT * FROM Clients'')' )

select * from openquery (Linkedservername,'select * from tablename')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM