sql2000发布订阅注意
使用的是事务发布和强行订阅。
-- 启用复制数据库
use master
GO
exec sp_replicationdboption @dbname = N'YujingWC', @optname = N'publish', @value = N'true'
GO
use [YujingWC]
GO
-- 添加事务发布
exec sp_addpublication @publication = N'YujingWC', @restricted = N'false', @sync_method = N'native', @repl_freq = N'continuous', @description = N'来自发布服务器 XYYJSERVER 的 YujingWC 数据库的事务性发布。', @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 = 0, @allow_queued_tran = N'false', @snapshot_in_defaultfolder = N'false', @alt_snapshot_folder = N'\\XYYJSERVER\D$\RData', @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', @logreader_job_name = N'XYYJSERVER-YujingWC-7'
exec sp_addpublication_snapshot @publication = N'YujingWC',@frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 0, @frequency_recurrence_factor = 1, @frequency_subday = 1, @frequency_subday_interval = 0, @active_start_date = 0, @active_end_date = 0, @active_start_time_of_day = 220500, @active_end_time_of_day = 0, @snapshot_job_name = N'XYYJSERVER-YujingWC-YujingWC-7'
GO
exec sp_grant_publication_access @publication = N'YujingWC', @login = N'BUILTIN\Administrators'
GO
exec sp_grant_publication_access @publication = N'YujingWC', @login = N'distributor_admin'
GO
exec sp_grant_publication_access @publication = N'YujingWC', @login = N'sa'
GO
-- 添加事务项目
exec sp_addarticle @publication = N'YujingWC', @article = N'ST_PPTN_R', @source_owner = N'dbo', @source_object = N'ST_PPTN_R', @destination_table = N'ST_PPTN_R', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_ST_PPTN_R', @del_cmd = N'CALL sp_MSdel_ST_PPTN_R', @upd_cmd = N'MCALL sp_MSupd_ST_PPTN_R', @filter = null, @sync_object = null, @auto_identity_range = N'false', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目筛选
EXEC sp_articlefilter @publication = N'YujingWC', @article = N'ST_PPTN_R', @filter_name = N'dbo.FLTR_ST_PPTN_R_1__56', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目同步对象
EXEC sp_articleview @publication = N'YujingWC', @article = N'ST_PPTN_R', @view_name = N'SYNC_YujingWC_ST_PPTN_R', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'ST_RIVER_R', @source_owner = N'dbo', @source_object = N'ST_RIVER_R', @destination_table = N'ST_RIVER_R', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_ST_RIVER_R', @del_cmd = N'CALL sp_MSdel_ST_RIVER_R', @upd_cmd = N'MCALL sp_MSupd_ST_RIVER_R', @filter = null, @sync_object = null, @auto_identity_range = N'false', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目筛选
EXEC sp_articlefilter @publication = N'YujingWC', @article = N'ST_RIVER_R', @filter_name = N'dbo.FLTR_ST_RIVER_R_1__56', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目同步对象
EXEC sp_articleview @publication = N'YujingWC', @article = N'ST_RIVER_R', @view_name = N'SYNC_YujingWC_ST_RIVER_R', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'ST_RSVR_R', @source_owner = N'dbo', @source_object = N'ST_RSVR_R', @destination_table = N'ST_RSVR_R', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_ST_RSVR_R', @del_cmd = N'CALL sp_MSdel_ST_RSVR_R', @upd_cmd = N'MCALL sp_MSupd_ST_RSVR_R', @filter = null, @sync_object = null, @auto_identity_range = N'false', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目筛选
EXEC sp_articlefilter @publication = N'YujingWC', @article = N'ST_RSVR_R', @filter_name = N'dbo.FLTR_ST_RSVR_R_1__56', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
-- 添加项目同步对象
EXEC sp_articleview @publication = N'YujingWC', @article = N'ST_RSVR_R', @view_name = N'SYNC_YujingWC_ST_RSVR_R', @filter_clause = N'stcd in (select stcd from st_stbprp_b where addvcd=(select ConfigValue from XT_ConfigPara where ConfigKey=''Addvcd'') )'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'YJ_STCD_Setting', @source_owner = N'dbo', @source_object = N'YJ_STCD_Setting', @destination_table = N'YJ_STCD_Setting', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_YJ_STCD_Setting', @del_cmd = N'CALL sp_MSdel_YJ_STCD_Setting', @upd_cmd = N'MCALL sp_MSupd_YJ_STCD_Setting', @filter = null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'YJ_User', @source_owner = N'dbo', @source_object = N'YJ_User', @destination_table = N'YJ_User', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_YJ_User', @del_cmd = N'CALL sp_MSdel_YJ_User', @upd_cmd = N'MCALL sp_MSupd_YJ_User', @filter = null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'YJ_user_dept', @source_owner = N'dbo', @source_object = N'YJ_user_dept', @destination_table = N'YJ_user_dept', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_YJ_user_dept', @del_cmd = N'CALL sp_MSdel_YJ_user_dept', @upd_cmd = N'MCALL sp_MSupd_YJ_user_dept', @filter = null, @sync_object = null, @auto_identity_range = N'false'
GO
exec sp_addarticle @publication = N'YujingWC', @article = N'YJ_user_headship', @source_owner = N'dbo', @source_object = N'YJ_user_headship', @destination_table = N'YJ_user_headship', @type = N'logbased', @creation_script = null, @description = null, @pre_creation_cmd = N'none', @schema_option = 0x00000000000000F3, @status = 16, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_YJ_user_headship', @del_cmd = N'CALL sp_MSdel_YJ_user_headship', @upd_cmd = N'MCALL sp_MSupd_YJ_user_headship', @filter = null, @sync_object = null, @auto_identity_range = N'false'
GO
-- 添加事务订阅
exec sp_addsubscription @publication = N'YujingWC', @article = N'all', @subscriber = N'AKSFXSERVER', @destination_db = N'YujingWC', @sync_type = N'automatic', @update_mode = N'read only', @offloadagent = 0, @dts_package_location = N'distributor', @distribution_job_name = N'XYYJSERVER-YujingWC-AKSFXSERVER-18'
GO