find the replications and articles from distribution server

zhouwf0726發表於2019-06-18

--according old upatedb replication, you may check the publication, then use the fllowing sql to find out these articles.
select * from MSpublications --check the publication

--according to publication, find out that these article.

select * from MSarticles where publication_id=1

select 'exec sp_addarticle @publication = N''analysis2_coredb_04'', @article = N'''+article+''', @source_owner = N''dbo'', @source_object = N'''+article+''', @destination_table = N'''+article+''', @type = N''logbased'', @creation_script = null, @description = null, @pre_creation_cmd = N''drop'', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N''false'', @ins_cmd = N''SQL'', @del_cmd = N''SQL'', @upd_cmd = N''SQL'', @filter = null, @sync_object = null, @auto_identity_range = N''false'' GO'
from MSarticles where publication_id=40


///All creation produre

-- Enabling the replication database
use master
GO

exec sp_replicationdboption @dbname = N'analysis2', @optname = N'publish', @value = N'true'
GO

use [analysis2]
GO

-- Adding the transactional publication
exec sp_addpublication @publication = N'analysis2_intranetdb', @restricted = N'false', @sync_method = N'character', @repl_freq = N'continuous', @description = N'Transactional publication of newjoyo2 database from Publisher DB-SELECT01.', @status = N'active', @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'false', @enabled_for_internet = N'false', @independent_agent = N'false', @immediate_sync = N'false', @allow_sync_tran = N'false', @autogen_sync_procs = N'false', @retention = 336, @allow_queued_tran = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @ftp_port = 21, @ftp_login = N'anonymous', @allow_dts = N'false', @allow_subscription_copy = N'false', @add_to_active_directory = N'false'
exec sp_addpublication_snapshot @publication = N'analysis2_intranetdb',@frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 1, @active_start_date = 0, @active_end_date = 0, @active_start_time_of_day = 0, @active_end_time_of_day = 235959
GO

exec sp_grant_publication_access @publication = N'analysis2_intranetdb', @login = N'BUILTINAdministrators'
GO
exec sp_grant_publication_access @publication = N'analysis2_intranetdb', @login = N'distributor_admin'
GO
exec sp_grant_publication_access @publication = N'analysis2_intranetdb', @login = N'sa'
GO

-- Adding the transactional articles
exec sp_addarticle @publication = N'analysis2_intranetdb', @article = N'TD007', @source_owner = N'dbo', @source_object = N'TD007', @destination_table = N'TD007', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL', @filter = null, @sync_object = null, @auto_identity_range = N'false' GO

-- Adding the transactional subscription
exec sp_addsubscription @publication = N'analysis2_intranetdb', @article = N'all', @subscriber = N'DB-BO', @destination_db = N'bo2', @sync_type = N'automatic', @update_mode = N'read only', @offloadagent = 0, @dts_package_location = N'distributor'
GO

exec sp_addsubscription @publication = N'analysis2_intranetdb', @article = N'all', @subscriber = N'DB-BO02-R1', @destination_db = N'bo2', @sync_type = N'automatic', @update_mode = N'read only', @offloadagent = 0, @dts_package_location = N'distributor'
GO

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-242470/,如需轉載,請註明出處,否則將追究法律責任。

相關文章