sqlserver跨服务器查询(个人总结)

--开始跨库
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

--跨库语句
select * from PJTMA WHERE MA001 not in
(select pjtma006 from OPENROWSET('SQLOLEDB','192.168.1.9';'sa';'SA',
   'SELECT * FROM EF2KWeb.dbo.pjtma') AS a )


--结束跨库后
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

你可能感兴趣的:(sqlserver)