跨服务器、跨库操作SQL

--在执行跨服务器查询之前,运行
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

insert into OPENDATASOURCE(
'SQLOLEDB',
'Data Source=地址;User ID=用户;Password=密码'
).数据库名.dbo.表名
select * from 本地表名

--查询结束后,运行
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

猜你喜欢

转载自www.cnblogs.com/vsnb/p/11597035.html