exec sp_configure ‘show advanced options‘,1 --开起
reconfigure
exec sp_configure ‘Ad Hoc Distributed Queries‘,1
reconfigure
Go
SELECT distinct([GoodsCode]) FROM OPENROWSET(‘SQLOLEDB‘,‘192.168.8.88‘;‘sa‘;‘123456‘,[Test].[dbo].[Customs])
exec sp_configure ‘Ad Hoc Distributed Queries‘,0 --关闭
reconfigure
exec sp_configure ‘show advanced options‘,0
reconfigure
sql server跨数据库查询,并启动Ad Hoc Distributed Queries
原文:https://www.cnblogs.com/wangtaobiu/p/13085139.html