Click here to Skip to main content
Email Password   helpLost your password?

Introduction

Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different locations and to remote or mobile users over local and wide area networks, dial-up connections, wireless connections, and the Internet.

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.

Terminologies before getting started:

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.

img01.png

Replication Types

Microsoft SQL Server 2005 supports the following types of replication:

Snapshot Replication
Transactional Replication
Merge 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

Before starting the replication process:

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

Steps:

  1. Open SQL Server Management Studio and login with SQL Server Authentication to configure Publishing, Subscribers, and Distribution

img02.png

a- Configure the appropriate server as publisher or distributor.

img03.JPG

b- Enable the appropriate database for merge replication

img04.png

2- Create new local publication from DB-Server --> Replication --> Local Publications --> Right Click --> New Pub

img05.jpg

then choose the database that contains the data or objects you want to replicate

img06.png

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

img07.png

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

img08.JPG

Then add filters to published tables to optimize performance and then configure the snapshot agent

img09.JPG

img10.png

and configure the security for snapshot agent

img11.JPG

finally rename the publication and click finish

img12.png

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

img13.JPG

img14.JPG

then choose one or more subscriber databases. you can add new SQL Server subscribers

img15.png

then specify the Merge Agent security as mentioned above on "Agent Snapshot"

and so specify the synchronization schedule for each agent.

Schedules:

img16.png

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

Advantages in Replication:

Users can avail the following advantages by using replication process:

Replication Performance Tuning Tips:

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.
 
 
Per page   
 FirstPrevNext
GeneralConfigurataion of my web synchronization in sql server 2005 ?
Tunisien86
0:49 17 Mar '10  
Hi guys,
I have a problem when synchronizing web publication.
I begin by giving you an insight into my soft installed:
sql-server 2005
7even-windows so IIS7.5
I created a publication MaPublication.I made a right click on publication-> Release Local> MaPublication then I chose to configure synchronization Web.Then, next-> sql server mobile-> created a new directory select default website ->next->in Alias: SQLCE-> 2 messages appear successively OK OK-> next-> clients connect anonymously-> next-> OHH now when I click on the Edit tab to change a user account error message appears:
The program can not open the required dialog box because no location has been found.Close this message and try again
What is the problem? Is it a problem IIS??
Thank you for your contribution
Note: the MSDN help don't help me anymore so another propositions
GeneralMy vote of 1
inspace 2009
23:45 17 Jan '10  
poorrrrrrrrrrrrrrrrrrr
GeneralI have problem setting up replication remotely
belzer
7:58 30 Jun '09  
This is a great article, and i wonder if you can help me, i am trying to setup replication between 2 remote computers, and I am having problems to setup the subscriber.

When I get to the point of "Choose the publication for which you want to create one or more subscriptions" i cannot login to the server database.

What Username\password do I need to enter there?


Thanks for you help
QuestionColumn Filter
Burak Donbay
23:40 3 Dec '08  
First of all, thanks for this good article.
I have a question.

I want to merge replicate 2 tables.
And all of them have 4 columns. Everything works fine when i replicate all columns.

But additionally, in another case i want to replicate only 3 ( both tables have 4 columns) columns. And when i try to do this, the 4th column in Subscription Database will be dropped automatically. How can avoid this?

Best regards.
QuestionSQL Server 2005 Replication implementation will change the publisher database?
Williams Wei
19:45 7 Oct '08  
Hello Group,

I have one question, when I implement merge replication on SQL 2000, it change the object structure,e.g. the table add a new column 'rowguid' even the table has primary key defined. SQL 2005 also does like this?

Thanks.

Williams
GeneralNew Publication?
Ian Uy
17:18 2 Sep '08  
Good Day,

I am using SQL Server 2005 Express Edition and I can't seem to find the "New Publication" context menu. Also, in the Replication folder, there is no "Local Publication" folder and only "Local Subscription".

What do I need to configure or install to have those objects?

Thanks! Smile

It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.

GeneralRe: New Publication?
Petros Amiridis
23:56 2 Sep '08  
Replication is not available in Express edition.


Last Updated 30 Aug 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010