Possible Duplicate:
Selecting data from two different servers in SQL Server可能重复:从SQL Server中的两个不同服务器中选择数据
How can I join two tables, which are located two different SQL Server instances, in one query?
如何在一个查询中连接两个位于两个不同SQL Server实例的表?
3 个解决方案
#1
21
The best way I can think of to accomplish this is via sp_addlinkedserver. You need to make sure that whatever account you use to add the link (via sp_addlinkedsrvlogin) has permissions to the table you're joining, but then once the link is established, you can call the server by name, i.e.:
我能想到的最好的方法是通过sp_addlinkedserver。您需要确保用于添加链接的任何帐户(通过sp_addlinkedsrvlogin)对您加入的表具有权限,但是一旦建立了链接,您就可以通过名称调用服务器,即:
SELECT *
FROM server1table
INNER JOIN server2.database.dbo.server2table ON .....
#2
9
You can create a linked server and reference the table in the other instance using its fully qualified Server.Catalog.Schema.Table name.
您可以使用其完全限定的Server.Catalog.Schema.Table名称创建链接服务器并在另一个实例中引用该表。
#3
3
If you are using SQL Server try Linked Server
如果您使用的是SQL Server,请尝试使用Linked Server
#1
21
The best way I can think of to accomplish this is via sp_addlinkedserver. You need to make sure that whatever account you use to add the link (via sp_addlinkedsrvlogin) has permissions to the table you're joining, but then once the link is established, you can call the server by name, i.e.:
我能想到的最好的方法是通过sp_addlinkedserver。您需要确保用于添加链接的任何帐户(通过sp_addlinkedsrvlogin)对您加入的表具有权限,但是一旦建立了链接,您就可以通过名称调用服务器,即:
SELECT *
FROM server1table
INNER JOIN server2.database.dbo.server2table ON .....
#2
9
You can create a linked server and reference the table in the other instance using its fully qualified Server.Catalog.Schema.Table name.
您可以使用其完全限定的Server.Catalog.Schema.Table名称创建链接服务器并在另一个实例中引用该表。
#3
3
If you are using SQL Server try Linked Server
如果您使用的是SQL Server,请尝试使用Linked Server