博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

Posted on 2010-07-05 17:20  大椰网吧  阅读(332)  评论(0编辑  收藏  举报

--开始跨库
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