Java教程

【sql】跨链接复制表

本文主要是介绍【sql】跨链接复制表,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
create database SampleTestingSysDB
go
use SampleTestingSysDB
go

EXEC sp_addlinkedserver
@server='oldDB',--被访问的服务器别名
@srvproduct='',
@provider='SQLOLEDB',
@datasrc='ip,端口' --要访问的服务器
go

EXEC sp_addlinkedsrvlogin
'oldDB', --被访问的服务器别名
'false',
NULL,
'sa', --帐号
'***' --密码
go

select * into [SampleTestingSysDB].dbo.Batch_Nucleic from  [oldDB].[SampleTestingSysDB].dbo.Batch_Nucleic
select * into [SampleTestingSysDB].dbo.Batch_NucleicSampleLog from  [oldDB].[SampleTestingSysDB].dbo.Batch_NucleicSampleLog
select * into [SampleTestingSysDB].dbo.Batch_Test from  [oldDB].[SampleTestingSysDB].dbo.Batch_Test
select * into [SampleTestingSysDB].dbo.Batch_TestSampleLog from  [oldDB].[SampleTestingSysDB].dbo.Batch_TestSampleLog
select * into [SampleTestingSysDB].dbo.Sample_BarCode from  [oldDB].[SampleTestingSysDB].dbo.Sample_BarCode
select * into [SampleTestingSysDB].dbo.Sample_Estimate from  [oldDB].[SampleTestingSysDB].dbo.Sample_Estimate
select * into [SampleTestingSysDB].dbo.Sample_Nucleic from  [oldDB].[SampleTestingSysDB].dbo.Sample_Nucleic
select * into [SampleTestingSysDB].dbo.Sample_ResultLog from  [oldDB].[SampleTestingSysDB].dbo.Sample_ResultLog
select * into [SampleTestingSysDB].dbo.Sample_Service from  [oldDB].[SampleTestingSysDB].dbo.Sample_Service
select * into [SampleTestingSysDB].dbo.Sys_Account from  [oldDB].[SampleTestingSysDB].dbo.Sys_Account
select * into [SampleTestingSysDB].dbo.Sys_AccountLog from  [oldDB].[SampleTestingSysDB].dbo.Sys_AccountLog
select * into [SampleTestingSysDB].dbo.Sys_AuthJoinAccountJoinPermissions from  [oldDB].[SampleTestingSysDB].dbo.Sys_AuthJoinAccountJoinPermissions
select * into [SampleTestingSysDB].dbo.Sys_AuthJoinResource from  [oldDB].[SampleTestingSysDB].dbo.Sys_AuthJoinResource
select * into [SampleTestingSysDB].dbo.Sys_AuthList from  [oldDB].[SampleTestingSysDB].dbo.Sys_AuthList
select * into [SampleTestingSysDB].dbo.Sys_AuthResource from  [oldDB].[SampleTestingSysDB].dbo.Sys_AuthResource
select * into [SampleTestingSysDB].dbo.Sys_Menus from  [oldDB].[SampleTestingSysDB].dbo.Sys_Menus


-- 删除登录
sp_droplinkedsrvlogin 'oldDB',null
go

--删除数据库连接
exec sp_dropserver 'oldDB'
go

这篇关于【sql】跨链接复制表的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!