The previous section describes the synchronization of databases through SQL jobs, which is a continuation of the previous chapter that enables synchronization between databases by publishing subscriptions. Publish a subscription for two steps: 1, release. 2 subscriptions. You first publish the data that needs to be synchronized on the data source database server, and then subscribe to the above publication on the target database server. A publication can publish part of a table's data, or it can publish an entire table. The following are the procedures for publishing, subscribing, and so on.
1, release. The publication requires the actual server name and cannot be performed using the server's IP address. The information that can be published includes "table", "Stored procedure", "User function" if there is an error using IP, the following figure:
The specific publishing process is as follows:
1. Locate "Copy" under the database server-"Publish locally" and select "New publication". The following figure:
2. Select the database to be published. The following figure:
3. Select the type of publication. The default type, "Snapshot Publishing," is selected here. The differences between several types of publishing are described below in SQL Server. The following figure:
4, select the class capacity to be released. The following figure:
The right side of the image above is the filtered SQL statement.
5, set the Snapshot Agent. The following figure:
Change the sync frequency as shown below:
6, set agent security. The following figure:
7, fill out the name of the publication
8, complete the release. The following figure:
2, Subscribe . A subscription synchronizes a snapshot of a database publication, synchronizing the published data source data to the target database. The specific subscription process is as follows;
1, find the database server under the "Replication"-"Local subscription", select "New Subscription." The following figure:
2, select the publication of the subscription. The following figure:
3, select the location of the Distribution Agent, as shown below:
4. Select one or more target databases at the Subscriber to store the data synchronized. The following figure:
To add more than one subscription database, click Add Subscriber. The following figure:
5, set the Distribution Agent security. The following figure:
6. Set up synchronization schedule. The following figure:
7, complete the subscription. The following figure:
This completes the entire process of publishing and subscribing.
Here, in conjunction with the previous section, we've covered two ways to synchronize SQL Server databases, and I hope it works for you.