![]() |
Database »
Database »
SQL Server
License: The Code Project Open License (CPOL)
SQL Server 2005 - Merge Replication Step by Step ProcedureBy Ahmad Eid SalimReplication is the process of sharing data between databases in different locations. Using replication, we can create copies of the database and share the copy with different users so that they can make changes to their local copy of database and later synchronize the changes to the source database |
SQL, Windows, Mobile, SQL-Server
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Replication is the process of sharing data between databases in different locations. Using replication, we can create copies of the database and share the copy with different users so that they can make changes to their local copy of database and later synchronize the changes to the source database.
Microsoft SQL Server 2000 supports the following types of replication
Publisher is a server that makes the data available for subscription to other servers. In addition to that, publisher also identifies what data has changed at the subscriber during the synchronizing process. Publisher contains publication(s).
Subscriber is a server that receives and maintains the published data. Modifications to the data at subscriber can be propagated back to the publisher.
Distributor is the server that manages the flow of data through the replication system. Two types of distributors are present, one is remote distributor and the other one local distributor. Remote distributor is separate from publisher and is configured as distributor for replication. Local distributor is a server that is configured as publisher and distributor.
Agents are the processes that are responsible for copying and distributing data between publisher and subscriber. There are different types of agents supporting different types of replication.
Snapshot Agent is an executable file that prepares snapshot files containing schema and data of published tables and database objects, stores the files in the snapshot folder, and records synchronization jobs in the distribution database.
An article can be any database object, like Tables (Column filtered or Row filtered), Views, Indexed views, Stored Procedures, and User defined functions.
Publication is a collection of articles.
Subscription is a request for copy of data or database objects to be replicated.
Microsoft SQL Server 2005 supports the following types of replication:
It allows making autonomous changes to replicated data on the Publisher and on the Subscriber. With merge replication, SQL Server captures all incremental data changes in the source and in the target databases, and reconciles conflicts according to rules you configure or using a custom resolver you create. Merge replication is best used when you want to support autonomous changes on the replicated data on the Publisher and on the Subscriber.
Replication agents involved in merge replication are snapshot agent and merge agent.
Implement merge replication if, changes are made constantly at the publisher and subscribing servers, and must be merged in the end.
By default, the publisher wins all conflicts that it has with subscribers because it has the highest priority. Conflict resolver can be customized
assume that we have 2 server:
on the publisher database i created table: Employees with fields of (ID, Name, Salary) to replicate its data to the subscriber server.
i will use publisher as subscriber also
Note: Check that SQL Server Agent is running on the publisher and the subscriber
a- Configure the appropriate server as publisher or distributor.
b- Enable the appropriate database for merge replication
2- Create new local publication from DB-Server --> Replication --> Local Publications --> Right Click --> New Pub
then choose the database that contains the data or objects you want to replicate
then choose the replication type and then specify the SQL server versions that will be used by subscribers to that publication like SQL Server 2005, SQL mobile Edition, SQL for Win CE ....etc
after that manage the replication articles, data and db objects, by choosing objects to be replicated
Note: you can manage the replication properties for selected objects
Then add filters to published tables to optimize performance and then configure the snapshot agent
and configure the security for snapshot agent
finally rename the publication and click finish

3- create a new subscription for the created "MyPublication01" Publication by right click on MyPublication01 --> New Subscription
that to configure the "Merge Agent" for replication on the subscriber database
then choose one or more subscriber databases. you can add new SQL Server subscribers

then specify the Merge Agent security as mentioned above on "Agent Snapshot"
and so specify the synchronization schedule for each agent.
Schedules:

and then next up to final step, then click finish
you can check the errors from "Replication Monitor" by right click on Local Replication --> Launch Replication Monitor
Users can avail the following advantages by using replication process:
TEXT, NTEXT or IMAGE data types. Thanks to "D J Nagendra", i used his article about sql 2000 replication from codeproject.com view to build the sql 2005 replication version.
thanks
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 30 Aug 2008 Editor: Chris Maunder |
Copyright 2008 by Ahmad Eid Salim Everything else Copyright © CodeProject, 1999-2010 Web18 | Advertise on the Code Project |