set nocount on go :CONNECT MYSERVER101\Publisher :ON ERROR EXIT if @@servername != 'MYSERVER101\Publisher' raiserror('Not connected to the right server.',16 ,1) GO use [ReplPlayground] exec sp_replicationdboption @dbname = N'ReplPlayground', @optname = N'publish', @value = N'true' GO -- Adding the transactional publication use [ReplPlayground] exec sp_addpublication @publication = N'TestPublication', @description = N'Transactional publication of database ''ReplPlayground'' from Publisher ''MYSERVER101\Publisher''.', @sync_method = N'concurrent', @retention = 336, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'false', @enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @ftp_port = 21, @allow_subscription_copy = N'false', @add_to_active_directory = N'false', @repl_freq = N'continuous', @status = N'active', @independent_agent = N'true', @immediate_sync = N'false', @allow_sync_tran = N'false', @allow_queued_tran = N'false', @allow_dts = N'false', @replicate_ddl = 1, @allow_initialize_from_backup = N'false', @enabled_for_p2p = N'false', @enabled_for_het_sub = N'false' GO exec sp_addpublication_snapshot @publication = N'TestPublication', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = null, @job_password = null, @publisher_security_mode = 1 use [ReplPlayground] exec sp_addarticle @publication = N'TestPublication', @article = N'MyTable', @source_owner = N'dbo', @source_object = N'MyTable', @type = N'logbased', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @identityrangemanagementoption = N'manual', @destination_table = N'MyTable', @destination_owner = N'dbo', @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dboMyTable', @del_cmd = N'CALL sp_MSdel_dboMyTable', @upd_cmd = N'SCALL sp_MSupd_dboMyTable' GO use [ReplPlayground] exec sp_addarticle @publication = N'TestPublication', @article = N'MyTableInfo', @source_owner = N'dbo', @source_object = N'MyTableInfo', @type = N'logbased', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @identityrangemanagementoption = N'manual', @destination_table = N'MyTableInfo', @destination_owner = N'dbo', @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dboMyTableInfo', @del_cmd = N'CALL sp_MSdel_dboMyTableInfo', @upd_cmd = N'SCALL sp_MSupd_dboMyTableInfo' GO -- Adding the transactional subscriptions use [ReplPlayground] exec sp_addsubscription @publication = N'TestPublication', @subscriber = N'MYSERVER101\Publisher', @destination_db = N'ReplPlaygroundSub', @sync_type = N'Automatic', @subscription_type = N'pull', @update_mode = N'read only' GO -----------------BEGIN: Script to be run at Subscriber 'MYSERVER103\Subscriber'----------------- :connect MYSERVER103\Subscriber if @@servername != 'MYSERVER103\Subscriber' raiserror('Not connected to the right server.',16 ,1) GO use [ReplPlaygroundSub] exec sp_addpullsubscription @publisher = N'MYSERVER101\Publisher', @publication = N'TestPublication', @publisher_db = N'ReplPlayground', @independent_agent = N'True', @subscription_type = N'pull', @description = N'', @update_mode = N'read only', @immediate_sync = 0 exec sp_addpullsubscription_agent @publisher = N'MYSERVER101\Publisher', @publisher_db = N'ReplPlayground', @publication = N'TestPublication', @distributor = N'MYSERVER102\Distributor', @distributor_security_mode = 1, @distributor_login = N'', @distributor_password = null, @enabled_for_syncmgr = N'False', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 1, @frequency_subday = 1, @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20110314, @active_end_date = 99991231, @alt_snapshot_folder = N'', @working_directory = N'', @use_ftp = N'False', @job_login = null, @job_password = null, @publication_type = 0 -----------------END: Script to be run at Subscriber 'MYSERVER103\Subscriber'-----------------