USE Database
go
SELECT * from syspublications
GO
USE Database
go
EXEC sp_dropsubscription
'Database_views_pub','SA2','SERVER4','Database'
go
USE Database
go
EXEC sp_dropsubscription
'Database_views_pub','vwCP','SERVER4','Database'
GO
---Taking out Views
USE Database
go
EXEC sp_droparticle
@publication = 'Database_views_pub',
@article = 'SA2',
@force_invalidate_snapshot = 1;
GO
USE Database
go
EXEC sp_droparticle
@publication = 'Database_views_pub',
@article = 'vwCP',
@force_invalidate_snapshot = 1;
GO
GO and drop views at SERVER4, otherwise it wont work
--Adding Back
use Database
go
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'allow_anonymous',
@value = 'false'
GO
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'immediate_sync',
@value = 'false'
GO
EXEC sp_addarticle @publication = N'Database_views_pub',
@article = N'SA2',---this is indexed view in publisher
@source_object=N'SA2',
go
SELECT * from syspublications
GO
USE Database
go
EXEC sp_dropsubscription
'Database_views_pub','SA2','SERVER4','Database'
go
USE Database
go
EXEC sp_dropsubscription
'Database_views_pub','vwCP','SERVER4','Database'
GO
---Taking out Views
USE Database
go
EXEC sp_droparticle
@publication = 'Database_views_pub',
@article = 'SA2',
@force_invalidate_snapshot = 1;
GO
USE Database
go
EXEC sp_droparticle
@publication = 'Database_views_pub',
@article = 'vwCP',
@force_invalidate_snapshot = 1;
GO
GO and drop views at SERVER4, otherwise it wont work
--Adding Back
use Database
go
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'allow_anonymous',
@value = 'false'
GO
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'immediate_sync',
@value = 'false'
GO
EXEC sp_addarticle @publication = N'Database_views_pub',
@article = N'SA2',---this is indexed view in publisher
@source_object=N'SA2',
@Type='indexed view schema only'
GO
EXEC sp_addarticle @publication = N'Database_views_pub',
@article = N'vwCP',--this is not indexed view
@source_object=N'vwCP',
@Type='view schema only'
GO
--Should run on publisher
EXEC sp_refreshsubscriptions @publication = N'Database_views_pub'
GO
----Should run on publisher
EXEC sp_startpublication_snapshot @publication = N'Database_views_pub'
go
----MUST
--enable back
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'immediate_sync',
@value = 'true'
GO
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'allow_anonymous',
@value = 'True'
GO
--Check on subscriber
GO
EXEC sp_addarticle @publication = N'Database_views_pub',
@article = N'vwCP',--this is not indexed view
@source_object=N'vwCP',
@Type='view schema only'
GO
--Should run on publisher
EXEC sp_refreshsubscriptions @publication = N'Database_views_pub'
GO
----Should run on publisher
EXEC sp_startpublication_snapshot @publication = N'Database_views_pub'
go
----MUST
--enable back
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'immediate_sync',
@value = 'true'
GO
EXEC sp_changepublication
@publication = 'Database_views_pub',
@property = N'allow_anonymous',
@value = 'True'
GO
--Check on subscriber
No comments:
Post a Comment