–服务器A (数据库表数据)导入数据至服务器B(数据库表数据)
use 服务器B(DB)
go
insert into dbo.table
–打开服务器数据库AC
exec sp_configure ‘show advanced options’,1
reconfigure
exec sp_configure ‘Ad Hoc Distributed Queries’,1
reconfigure
----注字段列可忽略自增列(ID)
insert into dbo.table (字段列1 ,
字段列2 ,
字段列3 ,
字段列… ,
字段列N)
select 字段列1 ,
字段列2 ,
字段列3 ,
字段列… ,
字段列N from OPENDATASOURCE(‘SQLOLEDB’,‘Data Source=服务器A链接;User ID=用户名;Password=密码’).DB.dbo.table where 条件
–关闭服务器数据库AC
exec sp_configure ‘Ad Hoc Distributed Queries’,0
reconfigure
exec sp_configure ‘show advanced options’,0
reconfigure
作者:runningbar
来源:优快云
原文:https://blog.youkuaiyun.com/u013597888/article/details/70153577
版权声明:本文为博主原创文章,转载请附上博文链接!