我有个网站,我要经常从远程服务器上把一个表备份到本地电脑的SQL数据库中。
我一直是删除本地SQL上的这个表,然后利用企业管理器的导入把远程服务器的整个表再创建复制过来。随着数据的增加,花费的时间越来越长,请问高手是否有简单的办法只追加远程服务器的新增加的数据过来?
我一直是删除本地SQL上的这个表,然后利用企业管理器的导入把远程服务器的整个表再创建复制过来。随着数据的增加,花费的时间越来越长,请问高手是否有简单的办法只追加远程服务器的新增加的数据过来?
insert into tb select * from servername2.dbname2.dbo.tb where id not in (select id from tb)也许这样的时间更长.不如清空表后全部插入来得快.
http://blog.csdn.net/fredrickhu/archive/2009/09/20/4573845.aspx
http://blog.csdn.net/fredrickhu/archive/2009/09/20/4572176.aspx
然后在本地機做
insert into tb select * from dbname2.dbo.tb where id not in (select id from tb) 這樣更加安全快捷
exec sp_addlinkedsrvlogin 'ITSV', 'false',null, 'sa', '123456'
insert into tb select * from servername2.dbname2.dbo.tb where id Not Exists (select id from tb)是这样的吗?
数据量大的话,还可以做成JOB,每天闲时执行。
你远程服务器的表可以修改么?增加一个timestamp列吧
之后每次只把最近更新的timestamp 拿过来
CREATE TABLE ExampleTable (PriKey int PRIMARY KEY, timestamp)
insert into ExampleTable select 1,null
select * from ExampleTable
select @@DBTSinsert into tb select ExampleTable where timestamp >(select max(timestamp) from tb )