Original: Remove and add publications in SQL Server replication without initializing all items
--If you "Prohibit schema changes" in advance, the new columns will not automatically add a large release, you should use Sp_articlecolumn to add the column exec sp_changepublication @publication = N ' publication ', @ property = N ' Replicate_ddl ', @value = 0--"Remove and add the publication without initializing all items, but the added item must be initialized"--Disallow anonymous access to exec sp_changepublication ' Publication ', ' allow_anonymous ', false go--Disable immediate update of EXEC sp_changepublication ' publication ', ' Immediate_sync ', false go-- Terminates a single item copy (the table is in the normal operation of the publication, the subscription should prohibit the operation) Exec sp_dropsubscription @publication = n ' publication ', @article = n ' article ', @subscriber = N ' Subscriber ', @destination_db = N ' destination_db ' go--delete the item from the publication (the interface operation will reinitialize so the project) Exec sp_droparticle @publication = n ' publication ', @article = n ' article ' go--add items to the release (@schema_option reference personal requirements change) Exec sp_addarticle @publication = ' Publication ', @article = n ' article ', @source_object = n ' article ', @source_owner = n ' dbo ', @schema_option = 0x0000000008037 Cdfgo--Add an unpublished column (add more columns to a published table, not typically) Exec sp_articlecolumn @publication = ' publication ', @article = N ' article ', @column = n ' column ', @operation = N ' Add ' go--for row filtering (for filtering publications) Exec sp_articlefilter @publication =n ' publication ', @article = n ' article ', @filter_name = N ' fltr_article_1__1 ', @filter_clause = n ' id% 2 = 0 ' GO--row filtering (used to filter the hair Cloth) Exec Sp_articleview @publication = n ' publication ', @article = n ' article ', @view_name = N ' sync_article_1__1 ', @filter_cl Ause = N ' id% 2 = 0 ' GO-Refresh subscription to add Project exec sp_refreshsubscriptions ' publication ' GO--start Snapshot Agent (Initialize new project) Exec Sp_startpublication _snapshot ' publication ' GO
Remove and add publications in SQL Server replication without initializing all items