从一个SQL Server Express复制到另一个SQL Server Express

时间:2021-01-31 10:21:06

I have one SQL Server Express instance with a pretty normal well formed database. I need to have the data continuously replicated to a SQL Server Express instance on another server.

我有一个SQL Server Express实例,其中包含一个非常正常的良好数据库。我需要将数据连续复制到另一台服务器上的SQL Server Express实例。

Now, I know that SQL Server Express does not include the Publisher part of built-in replication, so I'm looking for alternative solutions. I do not want to upgrade any of the databases.

现在,我知道SQL Server Express不包含内置复制的Publisher部分,所以我正在寻找替代解决方案。我不想升级任何数据库。

Naturally, I could make my own replication with guids, timestamps etc. and transfer the data using my own coding(as suggested in SQL Server Express database replication/synchronization), but I would want to avoid all that work, especially seeing that the replication is really very basic.

当然,我可以使用guids,timestamps等进行自己的复制,并使用我自己的编码传输数据(如SQL Server Express数据库复制/同步中所建议的那样),但我希望避免所有这些工作,特别是看到复制真的很基础。

Perhaps a generic trigger added to each table? Perhaps some kind of database job?

也许每个表都添加了一个通用触发器?也许某种数据库工作?

Any suggestions?

有什么建议么?

1 个解决方案

#1


3  

You wouldn't be able to utilize any built-in job scheduling, because Express does not ship with SQL Server Agent.

您将无法使用任何内置作业调度,因为Express不附带SQL Server代理。

Here's your options as far as I see it:

就我看来,这是你的选择:

  1. Write an application that transfers "articles" from your "publisher" db to your "subscriber" db(s)
  2. 编写一个应用程序,将“文章”从“发布者”数据库传输到“订阅者”数据库
  3. Create a set of views to have a summation of data that you want to be published. Then create INSTEAD OF triggers on these views (you can't create an AFTER/FOR trigger on a view) to process that data and transfer it to your "subscriber"(s).
  4. 创建一组视图以包含要发布的数据的总和。然后在这些视图上创建INSTEAD OF触发器(您无法在视图上创建AFTER / FOR触发器)来处理该数据并将其传输到“订户”。

Those are both not very intensive tasks. In my opinion, just to have it centralized I would go the first route. That way all of the logic is contained within the application, and your "publisher" database is ignorant to the replication. Not to mention your application could handle an unavailable subscriber pretty easy.

这些都不是非常密集的任务。在我看来,为了让它集中化,我会走第一条路线。这样,所有逻辑都包含在应用程序中,而您的“发布者”数据库对复制一无所知。更不用说您的应用程序可以很容易地处理不可用的订阅者。

#1


3  

You wouldn't be able to utilize any built-in job scheduling, because Express does not ship with SQL Server Agent.

您将无法使用任何内置作业调度,因为Express不附带SQL Server代理。

Here's your options as far as I see it:

就我看来,这是你的选择:

  1. Write an application that transfers "articles" from your "publisher" db to your "subscriber" db(s)
  2. 编写一个应用程序,将“文章”从“发布者”数据库传输到“订阅者”数据库
  3. Create a set of views to have a summation of data that you want to be published. Then create INSTEAD OF triggers on these views (you can't create an AFTER/FOR trigger on a view) to process that data and transfer it to your "subscriber"(s).
  4. 创建一组视图以包含要发布的数据的总和。然后在这些视图上创建INSTEAD OF触发器(您无法在视图上创建AFTER / FOR触发器)来处理该数据并将其传输到“订户”。

Those are both not very intensive tasks. In my opinion, just to have it centralized I would go the first route. That way all of the logic is contained within the application, and your "publisher" database is ignorant to the replication. Not to mention your application could handle an unavailable subscriber pretty easy.

这些都不是非常密集的任务。在我看来,为了让它集中化,我会走第一条路线。这样,所有逻辑都包含在应用程序中,而您的“发布者”数据库对复制一无所知。更不用说您的应用程序可以很容易地处理不可用的订阅者。