SQL SERVER –Replication Q &A

What are different replication agents and what’s their purpose?

What is the difference between Push and Pull Subscription?

Common Replication DMV's

Queued Updating Conflict Detection and Resolution

Because queued updating subscriptions allow modifications to the same data at multiple locations, there may be conflicts when data is synchronized at the Publisher. Replication detects any conflicts when changes are synchronized with the Publisher and resolves those conflicts using the resolution policy you selected when creating the publication. The following conflicts can occur:

Detecting Conflicts

When creating a publication and enabling queued updating, replication adds a uniqueidentifier column (msrepl_tran_version) with the default of newid() to the underlying table. When published data is changed at either the Publisher or the Subscriber, the row receives a new globally unique identifier (GUID) to indicate that a new row version exists. The Queue Reader Agent uses this column during synchronization to determine if a conflict exists.



Resolving Conflicts

When you create a publication using queued updating, you select a conflict resolver to be used if any conflicts are detected. The conflict resolver governs how the Queue Reader Agent handles different versions of the same row encountered during synchronization. You can change the conflict resolution policy after the publication is created as long as there are no subscriptions to the publication. The conflict resolver choices are the following:

Conflicts are recorded and can be viewed using the Conflict Viewer.

The Conflict Viewer displays information from three system tables:


Use this query to find out the article that is out of sync:

USE [distribution]

select * from dbo.MSarticles where article_id IN ( SELECT Article_id from MSrepl_commands where xact_seqno = 0x0003BB0E000001DF000600000000)

You can also check the error on browsing MSrepl_errors table in distribution database.

USE [distribution]

select*From MSrepl_errors

To get the exact command using either SP_BROWSEREPLCMDS (If CLR is enabled) or you can cast the command column in msrepl_commands table.

EXEC SP_BROWSEREPLCMDS

@xact_seqno_start = '0x0000044100002D930001',

@xact_seqno_end = '0x0000044100002D930001',

@publisher_database_id = 1033,

@article_id = 12,

@command_id= 1

Add a Table in the Publisher and add that to Article

Question:Is there any other way to Replicate that single Table without ReInitializing the SnapShot Again

1) Run the following (with your database and publication name):

USE <Database>

GO

EXEC sp_changepublication

@publication = 'MainPub',

@property = N'allow_anonymous',

@value = 'false'

GO


EXEC sp_changepublication

@publication = 'MainPub',

@property = N'immediate_sync',

@value = 'false'

GO

2) Add newarticle to the publication using UI.

3) Right click on the publication.    Select "View Snapshot Agent Status". Click on "Start" button.

This will generate snapshot for only the newly added articles

Add a Table in the Publisher and add that to Article

Question:Is there any other way to Replicate that single Table without ReInitializing the SnapShot Again

1) Run the following (with your database and publication name):

USE <Database>

GO

EXEC sp_changepublication

@publication = 'MainPub',

@property = N'allow_anonymous',

@value = 'false'

GO


EXEC sp_changepublication

@publication = 'MainPub',

@property = N'immediate_sync',

@value = 'false'

GO

2) Add newarticle to the publication using UI.

3) Right click on the publication.    Select "View Snapshot Agent Status". Click on "Start" button.

This will generate snapshot for only the newly added articles.

Error:I am getting the following error:

Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated,or you do not have permission.

Solution:Check Database properties owner its should not blank .must value there like sa.

Better output use the Result to Text as output in SSMS

SELECT CAST(SUBSTRING(command, 7, 8000) AS NVARCHAR(MAX)) FROM msrepl_commands WHERE xact_seqno = 0x0000044100002D930001

AND command_id = 1

 To disable SQL Server 2005 database replication

To delete local subscriptions to the replicated site database

 

    Important  Link:https://sites.google.com/site/saifsqlserverrecipes/sql-server-disable-replication