Selecting data from two different servers in SQL Server(从 SQL Server 中的两个不同服务器中选择数据)
问题描述
如何从 SQL Server 中两个不同服务器上的两个不同数据库中选择同一查询中的数据?
How can I select data in the same query from two different databases that are on two different servers in SQL Server?
推荐答案
您正在寻找的是链接服务器.您可以从对象资源管理器树中的以下位置在 SSMS 中找到它们:
What you are looking for are Linked Servers. You can get to them in SSMS from the following location in the tree of the Object Explorer:
服务器对象-->链接服务器
或者您可以使用 sp_addlinkedserver.
您只需设置一个.一旦你有了它,你就可以像这样调用另一个服务器上的表:
You only have to set up one. Once you have that, you can call a table on the other server like so:
select
*
from
LocalTable,
[OtherServerName].[OtherDB].[dbo].[OtherTable]
请注意,所有者并不总是 dbo
,因此请确保将其替换为您使用的任何架构.
Note that the owner isn't always dbo
, so make sure to replace it with whatever schema you use.
这篇关于从 SQL Server 中的两个不同服务器中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 SQL Server 中的两个不同服务器中选择数据


基础教程推荐
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01