Professional Documents
Culture Documents
SQL Server Replication
SQL Server Replication
SQL Server Replication
Problem
When preparing for a SQL Server interview there are several topics that could be
covered. In this tip we cover some possible interview questions and answers related
to SQL Server replication.
Solution
Here is a list of commonly asked replication interview questions or questions that may
come up during your routine DBA duties. I hope you find them useful.
EASY
Replication is subset of SQL Server that can move data and database objects in
an automated way from one database to another database. This allows users to
work with the same data at different locations and changes that are made are
transferred to keep the databases synchronized.
Pull - As the name implies, a pull subscription requests changes from the
Publisher. This allows the subscriber to pull data as needed. This is useful for
disconnected machines such as notebook computers that are not always
connected and when they connect they can pull the data.
Log Reader Agent - The Log Reader Agent is used with transactional
replication. It moves transactions marked for replication from the transaction
log on the Publisher to the distribution database. Each database
published using transactional replication has its own Log Reader Agent that
runs on the Distributor and connects to the Publisher (the Distributor can be on
the same computer as the Publisher)
Merge Agent - The Merge Agent is used with merge replication. It applies the
initial snapshot to the Subscriber and moves and reconciles incremental data
changes that occur. Each merge subscription has its own Merge Agent that
connects to both the Publisher and the Subscriber and updates both. The Merge
Agent runs at either the Distributor for push subscriptions or the Subscriber for
pull subscriptions.
Queue Reader Agent - The Queue Reader Agent is used with transactional
replication with the queued updating option. The agent runs at the Distributor
and moves changes made at the Subscriber back to the
Publisher. Unlike the Distribution Agent and the Merge Agent, only one instance
of the Queue Reader Agent exists to service all Publishers and publications for
a given distribution database.
Medium
2) What options are there to delete rows on the publisher and not on the
subscriber?
4) Data is not being delivered to Subscribers, what can be the possible reasons?
There are a number of possible causes for data not being delivered to
Subscribers:
o The table is filtered, and there are no changes to deliver to a given
Subscriber.
o One or more agents are not running or are failing with an error.
o Data is deleted by a trigger, or a trigger includes a ROLLBACK statement.
o A transactional subscription was initialized without a snapshot, and
changes have occurred on the Publisher since the publication was
created.
o Replication of stored procedure execution for a transactional publication
produces different results at the Subscriber.
o The INSERT stored procedure used by a transactional article includes a
condition that is not met.
o Data is deleted by a user, a replication script, or another application.
Hard
Tracer tokens were introduced with SQL Server 2005 transactional replication
as a way to monitor the latency of delivering transactions from the publisher to
the distributor and from the distributor to the subscriber(s). For details, please
refer tip to this tip: Monitor SQL Server replication latency using tracer tokens
2) If I create a publication with one table as an article, and then change the schema
of the published table (for example, by adding a column to the table), will the new
schema ever be applied at the Subscribers?
Yes this can be done using heterogeneous replication. In SQL Server 2000,
publishing data to other databases such as DB2 or Oracle was supported;
however, publishing data from other databases was not supported without
custom programming. In SQL Server 2005 and later versions, Oracle databases
can be directly replicated to SQL Server in much the same way as standard SQL
Server replication. For more information, please read tip: Introduction to SQL
Server Heterogeneous Replication
4) How will you monitor replication activity and performance? What privilege do you
need to use replication monitor?
The easiest way to monitor replication activity and performance is to use
replication monitor, but you can also use the below tools to monitor replication
performance:
o T-SQL commands. For more details refer msdn article
- http://msdn.microsoft.com/en-us/library/ms147874.aspx
o Microsoft SQL Server Management studio. For more details refer msdn
article - http://msdn.microsoft.com/en-us/library/ms152763.aspx
To monitor replication, a user must be a member of the sysadmin fixed server
role at the Distributor or a member of the replmonitor fixed database role in
the distribution database. A system administrator can add any user to the
replmonitor role, which allows that user to view replication activity in
Replication Monitor; however, the user cannot administer replication.
5) Can you tell me some of the common replication DMV's and their use?