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 中的两个不同服务器中选择数据


基础教程推荐
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 在多列上分布任意行 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01