Monday, March 21, 2011

SQL Server 2005 - 2008 – Snapshot Replication

In this blog I will show you the steps on how to replicate your tables from one database to the other database that might be on the same server or a different server. The same steps can be followed for both 2005 as well as 2008 SQL servers.

There are 2 databases that I will be using in this replication:

· AdventureWorks (Source Database)

· Books (Destination Database)

Setting Up the Publisher and Distributor:

clip_image002

Go to Replications section of the source server and right click on new publication:

clip_image004

clip_image006

Click Next:

clip_image008

clip_image010

You can specify the folder where the snapshot files should be placed:

clip_image012

Select the source database name:

clip_image014

Select the replication type: Snapshot replication in this case.

In my other blogs I will show how to create other types of replications :

clip_image016

Select the tables that you want to replicate:

clip_image018

Click on article properties to set the properties of the destination articles like the schema name for example. If you want the schema name of the destination table to be different from the source then you can specify it here:

clip_image020

clip_image022

Click Next:

You can specify the filter properties by clicking add:

clip_image024

clip_image026

Click Next:

clip_image028

Specify the security setting for the SQL server snapshot agent under what security context it should run:clip_image030

clip_image032

You can specify the windows account or the SQL server agent service account.

clip_image034

clip_image036

clip_image038

Specify a publication name:

clip_image040

clip_image042

The sql server jobs are automatically created for these operations that can be used to create a snapshot in future which you can schedule also.

clip_image044

clip_image046

The snapshot files are created in the folder that you had mentioned earlier:

clip_image048

Setting Up the Subscriber:

Right click on the local subscriptions in the replication pane of the destination server:

clip_image050

clip_image052

Select the publisher that you had created earlier:

clip_image054

clip_image056

Select the destination database where the replicated tables are to be stored:

clip_image058

Specify the security context as before as to how the agent has to run:

clip_image060

clip_image062

clip_image064

clip_image066

clip_image068

clip_image070

clip_image072

clip_image074

Refresh the database to see the replicated tables:

clip_image076

clip_image078

The subscription jobs are also created automatically:clip_image080

Source Table:

clip_image082

Destination table:

Schema name is different from the source if you had noticed as we had specified its property while setting up the publisher:clip_image084

1 comment:

Unknown said...

kya mama tum to gyan baatne laga be....