0% found this document useful (0 votes)
157 views

Replication Questions

Replication is the process of synchronizing data between databases. It involves a publisher, which makes data available, subscribers that receive the replicated data, and a distributor that stores replication data. There are different replication agents like snapshot, log reader, and distribution agents that facilitate the initial replication and ongoing data changes. Replication supports various types like snapshot, transactional, and merge, and can replicate between SQL Server and other databases.

Uploaded by

shyamyeole
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Replication Questions

Replication is the process of synchronizing data between databases. It involves a publisher, which makes data available, subscribers that receive the replicated data, and a distributor that stores replication data. There are different replication agents like snapshot, log reader, and distribution agents that facilitate the initial replication and ongoing data changes. Replication supports various types like snapshot, transactional, and merge, and can replicate between SQL Server and other databases.

Uploaded by

shyamyeole
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PART-1

1.Question 1. What Is Replication?


Answer :
Replication is the process of distributing data from one database to another
on the same server or servers connected through LAN or the internet.
Replication is used to synchronize data between databases that may be at
remote location.
2.Question 2. Describe In Brief Working Of Replication?
Answer :
At first data and object is synchronized between publisher and subscribers.
The snapshot is created on the publisher and transmitted to subscribers. All
the subsequent changes on the publisher are stored in distribution database.
Subscriber receives the data either using push or pull mechanism as
configured from distribution database.
3.Question 3. What Are Different Replication Agents And What's Their Purpose?
Answer :
Snapshot Agent:- The Snapshot Agent is used with all types of replication. It
prepares the schema and the initial bulk copy files of published tables and
other objects, stores the snapshot files, and records information about
synchronization in the distribution database. The Snapshot Agent runs at the
Distributor.
Log Reader Agent:-
o 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.
o 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).
Distribution Agent:- The Distribution Agent is used with snapshot replication
and transactional replication. It applies the initial snapshot to the Subscriber
and moves transactions held in the distribution database to Subscribers. The
Distribution Agent runs at either the Distributor for push subscriptions or at
the Subscriber for pull subscriptions.
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.
Queues 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.
4.Question 4. Does A Specific Recovery Model Need To Be Used For A
Replicated Database?
Answer :
Replication is not dependent on any particular recovery model. A database can
participate in replication whether it is in simple, bulk-logged, or full. However
how data is tracked for replication depends on the type of replication used.
5.Question 5. What Type Of Locking Occurs During The Snapshot Generation?
Answer :
Locking depends on the type of replication used:
o In snapshot replication, the snapshot agent locks the object during
the entire snapshot generation process.
o In transactional replication, locks are acquired initially for a very brief
time and then released. Normal operations on a database can
continue after that.
o In merge replication, no locks are acquired during the snapshot
generation process.
6.Question 6. What Options Are There To Delete Rows On The Publisher And Not
On The Subscriber?
Answer :
One option is to replicate stored procedure execution instead of the actual
DELETE command.  You can create two different versions of the stored
procedures one on the publisher that does the delete and the other on the
subscriber that does not do the delete.
Another option is to not replicate DELETE commands.
7.Question 7. Is It Possible To Run Multiple Publications And Different Type Of
Publications From The Same Distribution Database?
Answer :
Yes this can be done and there are no restrictions on the number or types of
publications that can use the same distribution database. One thing to note
though is that all publications from a Publisher must use the same Distributor
and distribution database.
8.Question 8. Data Is Not Being Delivered To Subscribers, What Can Be The
Possible Reasons?
Answer :
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.
9.Question 9. Explain What Stored Procedure Sp_replcounters Is Used For?
Answer :
Sp_replcounters is a system stored procedure that returns information about
the transaction rate, latency, and first and last log sequence number (LSN) for
each publication on a server. This is run on the publishing server. Running this
stored procedure on a server that is acting as the distributor or subscribing to
publications from another server will not return any data.
10. Question 10. How Will You Monitor Replication Latency In Transaction
Replication?
Answer :
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.
11. Question 11. 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?
Answer :
Yes. Schema changes to tables must be made by using Transact-SQL or SQL
Server Management Objects (SMO). When schema changes are made in SQL
Server Management Studio, Management Studio attempts to drop and re-
create the table and since you cannot drop a published objects, the schema
change will fail.
12. Question 12. Is It Possible To Replicate Data From Sql Server To Oracle?
Answer :
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.
13. Question 13. How Will You Monitor Replication Activity And Performance?
What Privilege Do You Need To Use Replication Monitor?
Answer :
The easiest way to monitor replication activity and performance is to use
replication monitor. 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.
14. Question 14. Can You Tell Me Some Of The Common Replication Dmv's And
Their Use?
Answer :
o sys.dm_repl_articles - Contains information about each article being
published. It returns data from the database being published and
returns a row for each object being published in each article.
o sys.dm_repl_schemas - Contains information about each table and
column being published. It returns data from the database being
published and returns one row for each column in each object being
published.
o sys.dm_repl_traninfo - Contains information about each transaction
in a transactional replication.
15. Question 15. What Are Publisher, Distributor And Subscriber In “replication”?
Answer :
Publisher: A publisher is any database unit that makes data available to other
sources via replication. The publisher can have multiple publications which
defines the data to replicate.
Subscriber: A subscriber is any database unit that receives the replicated
data. It can receive data from multiple publishers or publications. Data can be
republished to the other subscriber.
Distributor: A distributor is any database unit that acts as a store for the data
to be replicated. Each publisher is associated with a single database called as
distribution database. Replication status data is stored in distribution
database. A distributor can be local or remote.
16. Question 16. What Is “push” And “pull” Subscription?
Answer :
Pull Subscription:  In a pull subscription, changes to a subscriber cannot be
published without any request from subscriber. This allows the user at the
Subscriber to determine when the data changes are synchronized.
Push Subscription: In a push subscription, changes to a subscriber can be
published without any request from subscriber. The changes can be pushed
either periodically or on demand.
17. Question 17. What Are Different Models/types Of Replication?
Answer :
There are 3 types of replication:
o Snap shot replication
o Merge replication
o Trasctinal Replication
18. Question 18. What Is Snapshot Replication?
Answer :
o Snapshot of entire data is copied from publisher to the subscriber's
database on regular interval.
o This kind of replication is used for replicating data that doesn’t
change frequently.
o It is used where the source can manage with out of date data.
o This replication is considered when amount of data to be replicated
is small.
19. Question 19. What Is Merge Replication?
Answer :
o This allows both publisher and subscriber to work independently,
online or offline and merges the changes later.
o Here changes are track on both publisher and subscriber and then
merged.
20. Question 20. What Is A Transaction Replication?
Answer :
It is used when changes are frequent. The replication agent monitors the
changes at the publisher and distributes the changes to the subscribers.
Transactional Replication is required where up to date data is required.
21. Question 21. What Are The Uses Of Replication?
Answer :
Server to Server Replication:-
o Improving scalability and availability
o Data warehousing and reporting
o Integrating data from multiple sites
o Integrating heterogeneous data
o Offloading batch processing
Sverer to Client Replication:-
o Exchanging data with mobile users
o Retail point of sale (POS) applications
o Integrating data from multiple sites
22. Question 22. What Are The Agents Used For Transactional Replication?
Answer :
o Snapshot Agent
o Log Reader Agent
o Distribution Agent
23. Question 23. What Are The Agents Used For Merge Replication?
Answer :
o Snapshot Agent
o Merge Agent

PART-2

Question 1. What Is Sql Server Replication?


Answer :
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.
1.Question 2. What Are The Different Types Of Sql Server Replication?
Answer :
Snapshot replication - As the name implies snapshot replication takes a
snapshot of the published objects and applies it to a subscriber. Snapshot
replication completely overwrites the data at the subscriber each time a
snapshot is applied. It is best suited for fairly static data or if it's acceptable to
have data out of sync between replication intervals. A subscriber does not
always need to be connected, so data marked for replication can be applied
the next time the subscriber is connected.  An example use of snapshot
replication is to update a list of items that only changes periodically.
Transactional replication - As the name implies, it replicates each transaction
for the article being published. To set up transactional replication, a snapshot
of the publisher or a backup is taken and applied to the subscriber to
synchronize the data. After that, when a transaction is written to the
transaction log, the Log Reader Agent reads it from the transaction log and
writes it to the distribution database and then to the subscriber. Only
committed transactions are replicated to ensure data consistency.
Transactional replication is widely applied where high latency is not allowed,
such as an OLTP system for a bank or a stock trading firm, because you
always need real-time updates of cash or stocks. 
Merge replication - This is the most complex types of replication which allows
changes to happen at both the publisher and subscriber.  As the name implies,
changes are merged to keep data consistency and a uniform set of data. Just
like transactional replication, an initial synchronization is done by applying
snapshot. When a transaction occurs at the Publisher or Subscriber, the
change is written to change tracking tables. The Merge Agent checks these
tracking tables and sends the transaction to the distribution database where it
gets propagated.  The merge agent has the capability of resolving conflicts
that occur during data synchronization.  An example of using merge
replication can be a store with many branches where products may be
centrally stored in inventory. As the overall inventory is reduced it is
propagated to the other stores to keep the databases synchronized. 

2.Question 3. What Is The Difference Between Push And Pull Subscription?


Answer :
Push - As the name implies, a push subscription pushes data from publisher
to the subscriber. Changes can be pushed to subscribers on demand,
continuously, or on a scheduled basis. 
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. 

3.Question 4. What Are Different Replication Agents And What's Their Purpose?
Answer :
o Snapshot Agent- The Snapshot Agent is used with all types of
replication. It prepares the schema and the initial bulk copy files of
published tables and other objects, stores the snapshot files, and
records information about synchronization in the distribution
database. The Snapshot Agent runs at the Distributor. 
o 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) 
o Distribution Agent - The Distribution Agent is used with snapshot
replication and transactional replication. It applies the initial
snapshot to the Subscriber and moves transactions held in the
distribution database to Subscribers. The Distribution Agent runs at
either the Distributor for push subscriptions or at the Subscriber for
pull subscriptions. 
o 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. 
o 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. 
o
4.Question 5. Does A Specific Recovery Model Need To Be Used For A
Replicated Database?
Answer :
Replication is not dependent on any particular recovery model. A database can
participate in replication whether it is in simple, bulk-logged, or full. However
how data is tracked for replication depends on the type of replication used.
5.Question 6. What Type Of Locking Occurs During The Snapshot Generation?
Answer :
 Locking depends on the type of replication used:
o In snapshot replication, the snapshot agent locks the object during
the entire snapshot generation process.
o In transactional replication, locks are acquired initially for a very brief
time and then released. Normal operations on a database can
continue after that.
o In merge replication, no locks are acquired during the snapshot
generation process.
6.Question 7. What Options Are There To Delete Rows On The Publisher And Not
On The Subscriber?
Answer :
One option is to replicate stored procedure execution instead of the actual
DELETE command.  You can create two different versions of the stored
procedures one on the publisher that does the delete and the other on the
subscriber that does not do the delete.
Another option is to not replicate DELETE commands.
7.Question 8. Is It Possible To Run Multiple Publications And Different Type Of
Publications From The Same Distribution Database?
Answer :
Yes this can be done and there are no restrictions on the number or types of
publications that can use the same distribution database. One thing to note
though is that all publications from a Publisher must use the same Distributor
and distribution database.
8.Question 9. Data Is Not Being Delivered To Subscribers, What Can Be The
Possible Reasons?
Answer :
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.
9.Question 10. Explain What Stored Procedure Sp_replcounters Is Used For?
Answer :
Sp_replcounters is a system stored procedure that returns information about
the transaction rate, latency, and first and last log sequence number (LSN) for
each publication on a server. This is run on the publishing server. Running this
stored procedure on a server that is acting as the distributor or subscribing to
Question 11. How Will You Monitor Replication Latency In Transactional
Replication?
Answer :
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). 
10. Question 12. 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?
Answer :
Yes. Schema changes to tables must be made by using Transact-SQL or SQL
Server Management Objects (SMO). When schema changes are made in SQL
Server Management Studio, Management Studio attempts to drop and re-
create the table and since you cannot drop a published objects, the schema
change will fail.
11. Question 13. Is It Possible To Replicate Data From Sql Server To Oracle?
Answer :
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.  
12. Question 14. How Will You Monitor Replication Activity And Performance?
What Privilege Do You Need To Use Replication Monitor?
Answer :
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.
13. Question 15. Can You Tell Me Some Of The Common Replication Dmv's And
Their Use?
Answer :
o sys.dm_repl_articles - Contains information about each article being
published. It returns data from the database being published and
returns a row for each object being published in each article.
o sys.dm_repl_schemas - Contains information about each table and
column being published. It returns data from the database being
published and returns one row for each column in each object being
published
o sys.dm_repl_traninfo - Contains information about each transaction
in a transactional replication

You might also like