sqlserver中不同服务器不同数据库的表结构和表数据的复制

将90服务器上,TelemedicinePlatform_0511数据库中的hospital表和表数据复制到76服务器上,stu的数据库中

前提是:76服务器上,stu的数据库中没有hospital表

1.在76服务器上 启用网络传输

exec sp_configure 'show advanced options',1reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1reconfigure

2.在76服务器上相应的stu数据库中执行代码

use stu
go
SELECT * INTO dbo.hospital
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=192.168.1.90;User ID=sa;Password=sony'
).TelemedicinePlatform_0511.dbo.hospital

3.在76服务器上,关闭网络传输

exec sp_configure 'Ad Hoc Distributed Queries',0reconfigure exec sp_configure 'show advanced options',0reconfigure

二.同一个数据库中将表1 hospital 中的数据复制到表2 hoss中,前提条件是表1中的表结构要和表2中的表结构相同,这种情况是只复制数据

insert into hoss select * from hospital 

原文地址:https://www.cnblogs.com/cwyblog/p/2837085.html