sqlserver 跨服务器查询
--开启操作,无法跨服务器查询用一下解锁方法
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
--关闭操作
exec sp_configure 'show advanced options', 1;
reconfigure;
exec sp_configure 'Ad Hoc Distributed Queries', 0;
reconfigure;
--查询示例
select * from openrowset( 'SQLOLEDB', 'sql服务器名'; '用户名'; '密码',数据库名.dbo.表名)
--生成本地表
select * into 表 from openrowset( 'SQLOLEDB', 'sql服务器名'; '用户名'; '密码 ',数据库名.dbo.表名)
--把本地表导入远程表
insert openrowset( 'SQLOLEDB', 'sql服务器名'; '用户名'; '密码',数据库名.dbo.表名)
select *from 本地表
--更新本地表
update b
set b.列A=a.列A
from openrowset( 'SQLOLEDB', 'sql服务器名'; '用户名'; '密码',数据库名.dbo.表名)as a inner join 本地表 b
on a.column1=b.column1
Slowly I find myself