服务器A (数据库表数据)导入数据至服务器B(数据库表数据)

来源:互联网 发布:手机网络优化加速软件 编辑:程序博客网 时间:2024/05/28 17:08


--服务器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

 

0 0
原创粉丝点击