多台服务器上的SQL查询. [英] Sql query on Multiple servers.

查看:81
本文介绍了多台服务器上的SQL查询.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要在多服务器上编写查询.

就像Server1包含Database1一样,其中Database1包含Table1
以同样的方式,另一个服务器实例是Server2包含Database2,Database2包含Table2

我必须在上述指定的表之间创建联接.

我尝试使用中央管理服务器",但这对我没有帮助.


预先感谢.

Hi All,

I need to write a query on Mutlple servers.

like Server1 contains Database1 which contains Table1
in the same way another server instace is Server2 contains Database2 which contains Table2

i have to create a join between the above specified tables.

i tried with ''Central management servers'' but that doesn''t helps me.


Thanks in advance.

推荐答案

select    *
from    [OtherServerName].[OtherDB].[dbo].[OtherTable]



 SELECT        *
FROM        [SERVER2NAME].[THEDB].[THEOWNER].[THETABLE]





希望对您有所帮助.如果有帮助,请投票





Hope it will helpful. If helped Vote


您应将一台服务器链接到另一台服务器(有关详细信息,请参考以下链接:http://msdn.microsoft.com/en-us/library/ms188279.aspx [
You should link one server to another (please refer the following link for details: http://msdn.microsoft.com/en-us/library/ms188279.aspx[^]) and then you be able to create queries for example for query on server1
SELECT a.*, b.* FROM [Server2].[Database2].[YourSchema2].[Table2] AS a
  JOIN [Database1].[YourSchema1].[Table1] AS b
    ON a.SomeColumn2 = b.SomeColumn1


这篇关于多台服务器上的SQL查询.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆