一条语句实现跨服务器查询

exec sp_configure 'show advanced options',1

go
reconfigure

go

exec sp_configure 'Ad Hoc Distributed Queries',1

go

reconfigure

go
select * from OPENROWSET
(
'SQLOLEDB',
'SERVER=host;uid=user;pwd=pwd',
'select * from dbname..tbname'
)
exec sp_configure 'Ad Hoc Distributed Queries',0

go

reconfigure

go

exec sp_configure 'show advanced options',0

go

reconfigure

  

posted @ 2019-01-03 16:11  salv  阅读(117)  评论(0编辑  收藏  举报