SQL Server 跨库连接

-- 开启组件
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

-- 关闭组件
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
-- 查询远程数据库
SELECT *  FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.7.137;User ID=sa;Password=8818522').PanelData.dbo.Channel
原文地址:https://www.cnblogs.com/error503/p/5555828.html