[英]Best way to transfer data from source table in one db to destination table in another db daily
What would be the best way to transfer certain number of records daily from source to destination and then remove from source?每天将一定数量的记录从源传输到目的地然后从源中删除的最佳方法是什么?
DB - SQL server on cloud. DB - 云上的 SQL 服务器。
As the databases are in the same server, you can create a job that transfers the data do the other database.由于数据库位于同一台服务器中,您可以创建一个将数据传输到另一个数据库的作业。
Because the databases are in the same server you can easily access them, just by adding the database before the table in the query, look the test that i did:因为数据库位于同一台服务器中,您可以轻松访问它们,只需在查询中的表之前添加数据库,查看我所做的测试:
CREATE DATABASE [_Source]
CREATE DATABASE [_Destination]
CREATE TABLE [_Source].dbo.FromTable
(
some_data varchar(10)
)
CREATE TABLE [_Destination].dbo.ToTable
(
some_data varchar(10)
)
INSERT INTO [_Source].dbo.FromTable VALUES ('PAULO')
--THE JOB WOULD BE SOMETHING LIKE THIS:
-- INSERT INTO DESTINATION GETTING THE DATA FROM THE SOURCE
INSERT INTO [_Destination].dbo.ToTable
SELECT some_data
FROM [_Source].dbo.FromTable
-- DELETE FROM SOURCE
DELETE [_Source].dbo.FromTable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.