注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Oracle专业打杂

定会重回巅峰……

 
 
 

日志

 
 

【转】sqlserver数据库合并复制脚本  

2015-09-14 15:01:57|  分类: MSSQL高级 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
本文转载自寒塘渡鹤影《sqlserver数据库合并复制脚本》

订阅服务器上执行的脚本 :

        declare @db nvarchar(50)

declare @pubmachine nvarchar(50)

declare @pubdb nvarchar(50)

declare @pubname nvarchar(50)

 

set @db = 'experanimal'              % 订阅方数据库名

set @pubmachine = 'GJSYDW'         % 发布方机器名

set @pubdb = 'NLAC'                % 发布方数据库名

set @pubname = 'nlac'              % 发布名称

 

 

exec ('use ['+@db+ '] exec  sp_addmergepullsubscription @publisher = N'''+@pubmachine+''', @publication = N'''+@pubname+''', @publisher_db = N'''+@pubdb+''', @subscriber_type = N''Local'', @subscription_priority = 0, @description = N'''', @sync_type = N''Automatic''')

print ('use ['+@db+']')

print ('exec  sp_addmergepullsubscription @publisher = N'''+@pubmachine+''', @publication = N'''+@pubname+''', @publisher_db = N'''+@pubdb+''', @subscriber_type = N''Local'', @subscription_priority = 0, @description = N'''', @sync_type = N''Automatic''')

 

exec ('use ['+@db+ '] exec sp_addmergepullsubscription_agent @publisher = N'''+@pubmachine+''', @publisher_db = N'''+@pubdb+''', @publication = N'''+@pubname+''', @distributor = N'''+@pubmachine+''', @distributor_security_mode = 1, @distributor_login = N'''', @distributor_password = N'''', @enabled_for_syncmgr = N''False'', @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 4, @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @alt_snapshot_folder = N'''', @working_directory = N'''', @use_ftp = N''False'', @job_login = null, @job_password = null, @publisher_security_mode = 1, @publisher_login = N'''', @publisher_password = N'''', @use_interactive_resolver = N''False'', @dynamic_snapshot_location = N'''', @use_web_sync = 1, @internet_url = N''https://168.160.13.72/SQLReplication/replisapi.dll'', @internet_login = N''dbcopy'', @internet_password = ''CGC1nL@C?'', @internet_security_mode = 0, @internet_timeout = 300')

print ('use ['+@db+']')

print ('exec sp_addmergepullsubscription_agent @publisher = N'''+@pubmachine+''', @publisher_db = N'''+@pubdb+''', @publication = N'''+@pubname+''', @distributor = N'''+@pubmachine+''', @distributor_security_mode = 1, @distributor_login = N'''', @distributor_password = N'''', @enabled_for_syncmgr = N''False'', @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 4, @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @alt_snapshot_folder = N'''', @working_directory = N'''', @use_ftp = N''False'', @job_login = null, @job_password = null, @publisher_security_mode = 1, @publisher_login = N'''', @publisher_password = N'''', @use_interactive_resolver = N''False'', @dynamic_snapshot_location = N'''', @use_web_sync = 1, @internet_url = N''https://168.160.13.72/SQLReplication/replisapi.dll'', @internet_login = N''dbcopy'', @internet_password = ''CGC1nL@C?'', @internet_security_mode = 0, @internet_timeout = 300')

print ('GO')

 

发布服务器上执行的脚本:

 

declare @pubdb nvarchar(50)

declare @pubname nvarchar(50)

declare @submachine nvarchar(50)

declare @db nvarchar(50)

 

set @pubdb = 'NLAC'            发布方数据库

set @pubname = 'nlac'          新建发布的名称

set @submachine = 'JCS03'     订阅方机器名

set @db = 'experanimal'       订阅方数据库名

 

exec ('use '+@pubdb+' exec sp_addmergesubscription @publication = N'''+@pubname+''', @subscriber = N'''+@submachine+''', @subscriber_db = N'''+@db+''', @subscription_type = N''pull'', @subscriber_type = N''local'', @subscription_priority = 0, @sync_type = N''Automatic''')

print ('use '+@pubdb+' exec sp_addmergesubscription @publication = N'''+@pubname+''', @subscriber = N'''+@submachine+''', @subscriber_db = N'''+@db+''', @subscription_type = N''pull'', @subscriber_type = N''local'', @subscription_priority = 0, @sync_type = N''Automatic''')

不同的订阅方只需要修改相应的订阅数据库,机器名,发布方数据库名,发布方机器名,发布的名字,以及url中的IP地址即可。
  评论这张
 
阅读(46)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017