Friday, November 20, 2015

Add one table to existing publication



use dbname
go
EXEC sp_changepublication
@publication = ' Pub_name',
@property = N'allow_anonymous',
@value = 'false'
GO


EXEC sp_changepublication
@publication = 'pub_name'
@property = N'immediate_sync',
@value = 'false'
GO

EXEC sp_addarticle  @publication = N'Pub_name',
@article = N'Time',
@source_object=N'Time'
GO

 --same above if you another table


--Should run on publisher
EXEC sp_refreshsubscriptions @publication = N'Pub_name'
GO

 ----Should run on publisher
EXEC sp_startpublication_snapshot @publication = N'Pub_name'
go







---take out table from replication
--remove table from replication
 EXEC  sys.sp_dropsubscription
    @publication = N'Pub_name',
    @article = N'Time',
    @subscriber = N'SQL4',
    @destination_db = 'db_name'' ;
GO


EXEC sys.sp_droparticle
    @publication = N'Pub_name',
    @article = N'Time',
    @force_invalidate_snapshot = 1 ;
GO

No comments:

Post a Comment

https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context...