public
anonymous / gist:3152160
Created

Create Scripts

  • Download Gist
gistfile1.sql
SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
------ WORKING
use [thedb]
exec sp_addpublication @publication = N'thedb_THETABLE', @description = N'Transactional publication of database ''thedb'' from Publisher ''SOURCE''.', @sync_method = N'concurrent', @retention = 0, @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, @ftp_login = N'anonymous', @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', @autogen_sync_procs = N'false', @allow_queued_tran = N'false', @allow_dts = N'false', @logreader_job_name = N'SOURCE-thedb-7', @qreader_job_name = N'[DESTINATION].8'
GO
 
 
exec sp_addpublication_snapshot @publication = N'thedb_THETABLE', @frequency_type = 4, @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, @snapshot_job_name = N'SOURCE-thedb-thedb_THETABLE-60'
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'sa'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'BUILTIN\Administrators'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'DOMAIN\SvcSQL'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'DOMAIN\SQL Server Administrators'
GO
 
 
 
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'tTHETABLE100', @source_owner = N'dbo', @source_object = N'tTHETABLE100', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'tTHETABLE100', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dbotTHETABLE100', @del_cmd = N'CALL sp_MSdel_dbotTHETABLE100', @upd_cmd = N'MCALL sp_MSupd_dbotTHETABLE100'
GO
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'tTHETABLE192', @source_owner = N'dbo', @source_object = N'tTHETABLE192', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'tTHETABLE192', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dbotTHETABLE192', @del_cmd = N'CALL sp_MSdel_dbotTHETABLE192', @upd_cmd = N'MCALL sp_MSupd_dbotTHETABLE192'
GO
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'tTHETABLE199', @source_owner = N'dbo', @source_object = N'tTHETABLE199', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'tTHETABLE199', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dbotTHETABLE199', @del_cmd = N'CALL sp_MSdel_dbotTHETABLE199', @upd_cmd = N'MCALL sp_MSupd_dbotTHETABLE199'
GO
 
 
use [thedb]
exec sp_addsubscription @publication = N'thedb_THETABLE', @subscriber = N'DESTINATION', @destination_db = N'SOURCE_thedb', @subscription_type = N'Push', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @frequency_type = 64, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 4, @frequency_subday_interval = 5, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @offloadagent = 0, @dts_package_location = N'Distributor'
GO
 
--- NOT WORKING
 
use master
exec sp_replicationdboption @dbname = N'thedb', @optname = N'publish', @value = N'true'
GO
 
 
use [thedb]
exec sp_addpublication @publication = N'thedb_THETABLE', @description = N'Transactional publication of database ''thedb'' from Publisher ''SOURCE''.', @sync_method = N'concurrent', @retention = 0, @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, @ftp_login = N'anonymous', @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', @autogen_sync_procs = N'false', @allow_queued_tran = N'false', @allow_dts = N'false', @logreader_job_name = N'SOURCE-thedb-28', @qreader_job_name = N'[DESTINATION].8'
GO
 
 
exec sp_addpublication_snapshot @publication = N'thedb_THETABLE', @frequency_type = 4, @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, @snapshot_job_name = N'SOURCE-thedb-thedb_THETABLE-180'
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'sa'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'BUILTIN\Administrators'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'DOMAIN\SvcSQL'
GO
exec sp_grant_publication_access @publication = N'thedb_THETABLE', @login = N'DOMAIN\SQL Server Administrators'
GO
 
 
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'THETABLE100', @source_owner = N'dbo', @source_object = N'THETABLE100', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'THETABLE100', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dboTHETABLE100', @del_cmd = N'CALL sp_MSdel_dboTHETABLE100', @upd_cmd = N'MCALL sp_MSupd_dboTHETABLE100'
GO
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'THETABLE192', @source_owner = N'dbo', @source_object = N'THETABLE192', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'THETABLE192', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dboTHETABLE192', @del_cmd = N'CALL sp_MSdel_dboTHETABLE192', @upd_cmd = N'MCALL sp_MSupd_dboTHETABLE192'
GO
use [thedb]
exec sp_addarticle @publication = N'thedb_THETABLE', @article = N'THETABLE199', @source_owner = N'dbo', @source_object = N'THETABLE199', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x00000000000080A3, @auto_identity_range = N'false', @destination_table = N'THETABLE199', @destination_owner = N'dbo', @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_dboTHETABLE199', @del_cmd = N'CALL sp_MSdel_dboTHETABLE199', @upd_cmd = N'MCALL sp_MSupd_dboTHETABLE199'
GO
 
 
use [thedb]
exec sp_addsubscription @publication = N'thedb_THETABLE', @subscriber = N'DESTINATION', @destination_db = N'SOURCE_thedb', @subscription_type = N'Push', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @frequency_type = 64, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 4, @frequency_subday_interval = 5, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @offloadagent = 0, @dts_package_location = N'Distributor'
GO

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.