--打开
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.82.68;User ID=sa;Password=123456').[NWEPDI.EPDS].dbo.EventDefine
SELECT name FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.82.68;User ID=sa;Password=123456').[NWEPDI.EPDS].[SYS].[OBJECTS]
where TYPE = 'U'
--方法二
--创建链接服务器
exec sp_addlinkedserver 'ITSV ', ' ', 'SQLOLEDB ', '192.168.82.68'
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, 'sa', '123'
select TOP(10) * from ITSV.EPDS.dbo.EventDefine