Enable and Disable Schema Replication
Two sp_changepublication calls that turn DDL (schema change) replication on or off for a publication.
Transactional replication can optionally replicate schema changes (DDL) from the publisher to subscribers. This pair of scripts toggles that behavior for a single publication using the replicate_ddl property of sp_changepublication - run at the publisher with both @force_invalidate_snapshot and @force_reinit_subscription set to 0 so nothing is reinitialized.
/*
Run at the publisher to enable or disable the automatic replication of schema changes.
*/
--Enable schema change replication:
EXEC sp_changepublication
@publication = 'publication_name',
@property = 'replicate_ddl',
@value = 1, --Enable
@force_invalidate_snapshot = 0,
@force_reinit_subscription = 0
--Disable schema change replication:
EXEC sp_changepublication
@publication = 'publication_name',
@property = 'replicate_ddl',
@value = 0, --Disable
@force_invalidate_snapshot = 0,
@force_reinit_subscription = 0