sql - 如何通过注册服务器/服务器组查询多个服务器?
问题描述
我们使用某个医疗保健信息系统,将我们的医院分成多个服务器,我的公司正在发展壮大,这导致需要在 5 个以上的服务器数据库中运行一个简单的查询。
我最近了解了如何设置注册服务器本地组并进行设置。然后在尝试查询时碰壁。
问题是我们的数据库是基于环境的前缀,所以我需要一种方法来运行一个具有两个不同数据库表名的查询。
例子:
从现场fdb.dbo.BlahBlah 中选择 *
从测试fdb.dbo.BlahBlah 中选择 *
希望当我查询前 4 个字符使用通配符时有某种方法。
解决方案
You can do this but you'll have to use linked servers instead. Multi-server queries in SSMS won't work for you in this situation.
Given your constraints, I'd do this:
- On one server, create a linked server to the other servers.
- Create a view that queries each of the servers and uses UNION ALL to combine the results.
- Just query that view from one server.
推荐阅读
- c# - UNITY 方法没有重载需要 1 个参数
- android - 字体在模拟器和真实设备中都不会更新
- python - matplotlib - 图对象没有属性“绘图”。参考问题
- autodesk-viewer - 视图立方体不显示在 iPad 上
- ruby-on-rails - Heroku:在 /app/config/storage.yml 中找不到 Active Storage 配置(RuntimeError)
- java - 根据 List 的排序重新排序 Map
- javascript - 如何获得使用 node.js 的文本应用程序的语音?
- python - 在Python中以字符串格式从给定日期创建过去5个日期的列表
- r - 我不记得我是如何制作这个图表的,我必须为其他变量重新创建它。
- rest - [ApiException:调用 CreateEnvelope 时出错:]