SQL Server – How to re-initialize just a single article in transaction replication

 SQL Server – How to re-initialize just a single article in transaction replication -- Upskill 2020

1. Turn off @allow_anonymous and @immediate_sync on the publication.

use PUBLICATION_DB_NAME

go

EXEC sp_changepublication

@publication = 'Upskill2020_Test',

@property = N'allow_anonymous',

@value = 'false'

GO

 

EXEC sp_changepublication

@publication = 'Upskill2020_Test',

@property = N'immediate_sync',

@value = 'false'

GO

The reason we must disable @immediate_sync is because every time you add a new article, and if @immediate_sync is 

enabled, it will cause the entire snapshot to be applied. Our objective is to only apply a particular article.

2. Add new article.

EXEC sp_addarticle

@publication = 'Upskill2020_Test',

@article = 'Employee',

@source_object = 'Employee',

@force_invalidate_snapshot = 1

3. Refresh the subscription

EXEC sp_refreshsubscriptions @publication = 'Repl_RBD'

GO

4. Check the current snapshot agent history.

use distribution

go

select * from dbo.MSsnapshot_history

5. Start Snapshot agent.

EXEC sp_startpublication_snapshot @publication = 'Upskill2020_Test';

GO


6. Check the Snapshot Agent history again. You should see a snapshot generated only for the newly added article/s.


7. Turn ON @allow_anonymous and @immediate_sync on the publication.

use PUBLICATION_DB_NAME

go

EXEC sp_changepublication

@publication = 'Upskill2020_Test',

@property = N'immediate_sync',

@value = 'true'

GO

EXEC sp_changepublication

@publication = 'Upskill2020_Test',

@property = N'allow_anonymous',

@value = 'true'



Comments

Popular posts from this blog

SQL Deadlock Report - Extended Events

DBA Daily Commands in Handy