SQL Server disable replication

938 views Asked by At

I have a replicated database on my SQL server that is accessed from another SQL server. From this database, not all tables are replicated, just some ones. When I have to make changes in these tables, I have to disable the replication first, otherwise it does not allow me to make changes in these tables.

The place where I turn off the replication of these tables is the following location:

Replication > Local Publications > Properties > Articles > Tables

I would like to be able to deactivate and activate the replication of these tables from my custom program/script, using SQL statements. I have seen that when I remove tables from replication, the following columns of sys.tables change, but I don't know if anything else changes:

SELECT *
FROM sys.tables
where name = 'AdventureTable'

is_published = 0 or 1
is_replicated = 0 or 1

How should I do this properly?

1

There are 1 answers

0
Archlight On

Use the system procedure sp_dropmergearticle.

You need to know the sysname of the replication and the sysname of the table (Article)

exec sp_dropmergearticle N'MyPublishingName', N'MyTableName'

For more help you can see : SQL Docs