怎么将sqlyog10预览版升级正式版为正式版

您所在的位置: &
SQLyog使用介绍
SQLyog使用介绍
SQLyog 是一个易于使用的、快速而简洁的图形化管理MYSQL数据库的工具,它能够在任何地点有效地管理你的数据库,而且它本身是完全免费的!
SQLyog 是一个易于使用的、快速而简洁的图形化管理MYSQL数据库的工具,它能够在任何地点有效地管理你的数据库,而且它本身是完全免费的!
启动sqlyog(以下简称为软件)5.11版本为英文版,(建议使用英文版,中文版反映速度很慢,容易出现锁死现象.)会出现提示框,选择,Thank you, but I am not interested in either of the above-mentioned proned products,Just let me continue...意思是 ,谢谢,我对上述产品不感兴趣,仅使用此软件就可以了.
然后选择连接属性,点击new按钮,为连接起一个名字,比如&我的网站&在弹出框中输入,我的网站,点击OK完成建立.
Mysql Host Address:数据库的主机名称,可以填写你的域名
User Name:连接数据库的用户名.
Password:连接数据库的密码.
SavePassword:是否保存密码方便下次登陆,(建议不要选择,一是为了安全性着想,二是经常使用不输入密码的连接,以后你就会忘记密码)
Prot:端口号为3306(服务器令行通知的情况例外,请自行修改)
Default Charset连接的字符集,请选择默认.
登陆成功后你会看到3个数据库,一个information_schema,和test这个是系统使用的数据库,不要动他,剩下的一个就是你的数据库了,点在点他前面的加号,或双击打开他,在要修改的表上面按右键,然后选择insert .updata Data for the table 或者快捷键F11,然后直接编辑表中的数据即可,编辑好后记得一定要点以下show all or旁边的存档图标,以保存修改,show all or 是列出全部记录,后面的数字是可以选择列出从0到多少条以后的数据,按Refresh确认.
如果要删除多余的记录,请在要删除的记录前面的方块里打对号,并点击show all or 旁边的存档上面带一个红色X的图标,进行删除处理.
其他操作都需要数据库管理权限的,对于只使用数据库的用户来说没有任何意义,本文只介绍如何更方便的远程使用mysql数据库,并不涉及对整个mysql数据库的管理.
注意:sql操作是不可恢复的操作项,使用时候一定要注意,不然后果相当严重!!切记!
用SQLyog来分析MySQL数据库
SQLyog的下载、安装以及使用很简单。我去了相关网站下载,它只有384K字节大小。它把两个文件(一个可执行文件.exe和一个动态链接库文件.dll)安装到C:\Program Files\SQLyog路径下。然后运行可执行文件。
安装后没有必要再访问该网站了,我访问该网站是得到了一个消息,说它的域名没有设置(configured)、登记、或正在建设中。我不清楚这个问题是暂时的还是一直是这样。该软件是免费的,并且没有标志广告(banner ads),所以它可能是一个特定的尚未最终定型的商业模型。最终可能还是要负费的。
Grok the yog
yog是什么?如果你是Heinlein的追随者(参考他的作品&Stranger in a Strange Land&),那么你一定熟悉&grok&这一新造出来的单词,它的大意是&完全的、几乎移情的理解&。&Yog&是一个印地语词汇,其语意大致可以和 &grok&相同。所以,如果你不是Heinleinian的追随者,从现在起到grok SOLyog的全部内容只是600页的资料而已。
数据库、表格(table)和列树(column tree)
该程序一启动就开始询问我的登录到MySOL服务器的口令。我只需要输入我的服务器名字、用户id和登录密码。所有其它的设置都是正确的默认值。然后(当我开始其它事务、重启几次、睡了一会之后),我重新运行该程序,这时只需要再次输入我的登录密码。该程序没有保存密码的选项,你可以认为这是该程序的一个bug,也可以说是程序的保密特性。
一旦你登录之后,界面就是很值得注意。MySOL服务器上所有的数据库都显示在一个树型控件上。你只能访问你在登录时授权的那个数据库。如果你点开代表授权给你的那个数据库的树型结构,你就可以看到一系列代表表格的节点。点开表格节点后,你就可以看到一系列显示字段名的节点和另一个代表索引的节点集合。
索引界面绝对是个好东东,这样你就可以CRUD查询索引和关键字了。这相对前端数据库如Microsoft Access来说是个提高。如果考虑到MySOL刚刚开始提供对主(primary)和非相关(foreign)关键字关系的支持,本程序这部分的设计是很成熟的。在右下方的面板上,有四个标签页,即:结果(Result)、消息(Message)、对象(Object)和历史(History)。
有什么缺点?
我试图发现该程序的缺点,不过只发现了一个。如果你在Win32 Dependency Walker下运行程序的.exe文件,你会发现它引用了COMDLG32.dll文件,而COMDLG32.dll又轮流引用AppHelp。实事上,CommDlg调用AppHelp,而当AppHelp没有请求函数时,CommDlg这么做根本就是浪费资源。
过于简单?
在SQLyog FAQ上,有一种观点认为该软件没有正式归档的必要。当然,FAQ(常见问题解答)本身就是一种归档。SQLyog的界面非常直观。我建议你打印一份MySOL文档(包括SQL特殊语法扩展)。我就是这么做的,它只用了一个半英寸的活页封面。
最后一步?
FAQ还让人想到一个让人耳朵起了老茧却又是正确的Occam's Razor准则&&一切超出必要的复杂性都是没有必要的。我之所以到处&推销&这个工具,就是因为它可以为我们提供一个可以管理MySOL服务器上许多数据库的、简单的、图形化的界面。它的速度极快,并且它的拷贝很小(可以放在一张软盘上)。
SQLyog宣称自己是一个查询分析器,实际上它的功能远远不止这些。我真的很想全面介绍它的所有功能和特性,但是这太多了。如果你使用MySOL,我建议你在它的网站下载SQLyog(需要登记你的名字和电子邮件地址),然后安装并感受一下它的功能。
=================================================
SQLyog具有以下功能:
快速备份和恢复数据。
以GRID/TEXT格式显示结果。
支持客户端挑选、过滤数据。
批量执行很大的SQL脚本文件。
快速执行多重查询并能够返回每页超过1000条的记录集,而这种操作是直接生成在内存中的。
程序本身非常短小精悍!压缩后只有348 KB。
完全使用MySQL C APIs程序接口。
以直观的表格界面建立或编辑数据表。
以直观的表格界面编辑数据。
进行索引管理。
创建或删除数据库。
操纵数据库的各种权限:库、表、字段。
编辑BLOB类型的字段,支持Bitmap/GIF/JPEG格式。
输出数据表结构/数据为SQL脚本。
支持输入/输出数据为CSV文件。
可以输出数据库清单为HTML文件。
为所有操作建立日志。
个人收藏管理操作语句。
支持语法加亮显示。
可以保存记录集为CSV、HTML、XML格式的文件。
99%的操作都可以通过快捷键完成。
支持对数据表的各种高级属性的修改。
查看数据服务器的各种状态、参数等。
支持更改数据表类型为ISAM、MYISAM、MERGE、HEAP、InnoDB、BDB。
刷新数据服务器、日志、权限、表格等。
诊断数据表--检查、压缩、修补、分析。
下面简要介绍SQLyog的基本使用。
SQLyog的安装与设置
针对SQLyog的简要操作步骤如下。
1. 下载并安装SQLyog
SQLyog软件可以在SQLyog的官方网站(/en/)或者华军软件园(http://www.onlinedown.net)下载,目前的最新版本为8.03。双击下载的exe文件,按照相应的提示进行安装即可。
2. 设置MySQL用户
数据库在创建之时,权限为root,然而每个普通用户并不需要这么高的权限,基于安全考虑也并不能分配这样的权限给使用者,所以在此为MySQL增加一个新的用户。
添加新用户的命令格式为:
grant select on 数据库.* to 用户名@登录主机 identified by &密码&
在此增加一个用户并将名称和密码都设为&zyj&,它只可以在localhost主机上登录,只对testmysql数据库有创建、查询、插入、修改、删除的权限。启动MySQL的客户端,并键入以下命令进行操作:
3. 通过SQLyog来连接MySQL
(1) 执行File&New connection菜单命令。将打开连接提示对话框。单击New按钮,将创建一个新的连接,给新连接定义一个名字&zyj&。
(2) 单击OK按钮,在MySQL的设置窗体输入相关的数据。注意Port是安装MySQL时默认的访问端口,如果安装时未修改,则默认值为3306。
(3) 当单击Test Connection按钮时,将弹出Connection Info对话框。如果提示连接失败,请确定输入的用户名、密码或端口号是否正确。
(4) 当单击&确定&按钮后,就完成了SQLyog与MySQL的连接。接下来就可以通过SQLyog来进行MySQL的相关操作了。
表的相关操作
SQLyog的最大优点就是简化了对MySQL的操作,这里只是简要地罗列了与表相关的操作。
在左侧的导航中选择所要操作的数据库,单击鼠标右键,从弹出的快捷菜单中选择Create Table命令,创建新表。
2. 设置字段
在弹出的界面中,输入字段名(Field Name),设置字段类型(Datatype),设置字段长度(Len),对于一些字段还可以设置相关的约束--常用的选项有主键约束(PK)、非空约束 (Not Null)、自增长(Auto Increment)。
字段内容设置完之后,单击Create Table按钮,设置表名,即可完成表的创建。当然也可以直接运行SQL语句,在代码区域输入相应的SQL语句,然后执行语句,即可完成相应的操作。
3. 添加数据
在左边的导航栏选中要操作的表,在右边选择Table Data,然后可以直接输入相关数据来完成添加数据的任务。
4. 备份数据
单击Export as按钮,可以将此表输出为各种格式保存,通常保存为SQL语句,在保存的时候可以选择要输出的字段。
输出的SQL文件位于SQLyog所在的目录之中。打开SQL文件可以看到输出的标准SQL语句。
也可以在数据库上单击鼠标右键,从弹出的快捷菜单中执行Backup Database As命令,将整个数据库的所有内容备份为SQL文件。
============
说实话SQLyog不好汉化,居多的资源,光非标部分ASCII、Unicode、UTF-8字符串都有,而且汉化很容易出bug。对ASCII的字符依然不知如何进行汉化,我直接写入汉字在运行后就会是乱码,这次我对Unicode、UTF-8进行了独立汉化,在汉化8.12版时的很多问题都解决了。所以这次汉化率会比上次高些,但仍然不是完全,我尽我最大努力了。
这个版本同样没有汉化完全,对非标字符的汉化还是很棘手,这次发现Athena-A能在译文比原字符长时使用挪位,但我只会使用&超写&的功能,而且当可用的空白位不够时同样不知如何处理,无奈!
快捷键对照表那块Athena-A无法找到,使用eXeScope到是能进行汉化,原本这一块已经汉化完了的,但在一次操作时覆盖掉了,所以就不再重复一次了,这次仍然是英文的。^0^ God!!!
来张汉化后的图
498)this.width=498;' onmousewheel = 'javascript:return big(this)' style="width: 563 height: 361px" border="0" alt="" src="/files/uploadimg/3580.png" width="873" height="607" />
这次SQLyog更改了注册算法,以前的注册机没用了,但我找到个可用的注册码,也分享出来吧!
Name: AnyRegistration Code: 26f359fc-e3f6--72a1a4a0819d
原文链接:/tdalcn/archive//1988665.html
【编辑推荐】
【责任编辑: TEL:(010)】
关于&&的更多文章
MySQL 5.6.10已经发布,Oracle将其称之为MySQL 5.6正式版。51CTO
数据库产品
数据库综合
数据库新闻
维基百科将切换到另外一款开源数据库MariaDB
这个专题系统地介绍和分析比较了业界主流的Yahoo! S4
数据挖掘,越来越多的体现在企业的数据报表上,也会为
每一次的发展,都是一次上升,一次变革,看似回到了原
20多年以来,《软件工程:实践者的研究方法》一书是最受学生和行业专业人员欢迎的软件工程指南。它在全面而系统、概括而清晰地介
51CTO旗下网站经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。
请扫描分享到朋友圈当前位置&&&&&&&&&MySQL管理工具SQLyog最新6.1下载
更多文章查询:&
MySQL管理工具SQLyog最新6.1下载
&&&&&&&日08:26&&来源:&&作者:Zzyq&&
【文章摘要】现在不少朋友都自己搭建了个人主页或者博客程序什么的,MySQL的利用率因而也大大提高,一款方便的让工作效率提升不少的MySQL管理工具因而也就成了很多朋友需求的工具之一。
  现在不少朋友都自己搭建了个人主页或者博客程序什么的,MySQL的利用率因而也大大提高,一款方便的让工作效率提升不少的MySQL管理工具因而也就成了很多朋友需求的工具之一。   SQLyog是业界著名的Webyog公司出品的一款简洁高效、功能强大的图形化MySQL数据库管理工具,使用SQLyog可以快速直观地让您从世界的任何角落通过网络来维护远端的MySQL数据库。   SQLyog相比其它类似的MySQL数据库管理工具其有如下特点:  1、基于C++和MySQL API编程;   2、方便快捷的数据库同步与数据库结构同步工具;   3、易用的数据库、数据表备份与还原功能;  4、支持导入与导出XML、HTML、CSV等多种格式的数据;  5、直接运行批量 SQL 脚本文件,速度极快;   6. 新版本更是增加了强大的数据迁移组件;  注意:此汉化基于企业零售版,拥有免费版和专业版所没有的专业组件(如:数据迁移、数据同步、通知服务等),是MySQL DBA的必备工具。   下载页面:  
热门推荐:
责任编辑:彭凡
&关于&sqlyog mysql&相关报道
&硅谷动力最新热点
loading...
频道热文排行
经典软件下载
往期精彩文章
网站合作、内容监督、商务咨询、投诉建议:010-
Copyright © 2000--
硅谷动力公司版权所有 京ICP证000088号iphone5越狱后如何升级ios7正式版 iPhone5升级ios7正式版教程
&& 12:28:22.0&&编辑:sky
iphone5 ios7正式版固件下载地址
&&&&&&& iOS 7正式版于9月19日凌晨发布,在经过几天的体验后许多用户反映iOS 7正式版存在Bug,近日锁屏Bug以及中文输入法Bug相继爆出,不过这并不影响iOS 7正式版固件下载的热度。据了解,48小时iOS 7正式版固件装机率达43%,这样的普及速度十分火爆。接下来小编与大家分享iOS 7.0正式版官方下载地址及iphone5 ios7正式版固件下载地址。  iPhone 5 (GSM) (iPhone5,1)  /iOS7/091-8.FuFu4/iPhone5,1_7.0_11A465_Restore.ipsw  iPhone 5 (CDMA) (iPhone5,2)  /iOS7/091-8.9Fu45/iPhone5,2_7.0_11A465_Restore.ipsw  iPhone5,3 (iPhone5,3) (5c)  /iOS7/031-4.DoOPv/iPhone5,3_7.0.1_11A470a_Restore.ipsw  iPhone5,4 (iPhone5,4) (5c)  /iOS7/031-4.rHLcE/iPhone5,4_7.0.1_11A470a_Restore.ipsw&&&&&&& 在教程开始之前需要说明的是已经解锁或者越狱的用户请谨慎升级,因为升级iOS7之后就只能降级到iOS 6.1.4了,届时你就无法再越狱或者解锁了。如果你不在乎的话就往下看吧,在开始之前你需要先把你的手机刷至iOS6最新版。&&&&&&& 具体教程如下:&&&&&&& 1、首先下载最新版的iTunes 11.0.4,下载地址:/xiazai/4/108/16555.html&&&&&&& 2、下载机型相应的iOS7固件,下载地址如下(部分链接为国外网盘,推荐使用Chrome浏览器进行下载):&&&&&&& iPhone 5(Model A1428) :仅供北美(美国、加拿大)AT&T版本&&&&&&& iPhone 5(Model A1429):电信/联通国行、港行等,除北美AT&T版本之外
第1页:iphone5 ios7正式版固件下载地址
相关阅读:
所属分类:文章详情
登录:&&&&&&&&&&&&&&SQL复制订阅之服务器创建发布
【娱乐休闲】
【生活服务】
【电脑网络】
【文体教育】
【行业部门】
文章浏览→→→SQL复制订阅之服务器创建发布SQL复制订阅之服务器创建发布
&SET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @ReturnCode &&INT----------------------------- Initialize variable(s)---------------------------SET @PublisherName = N''+ @@SERVERNAME + ''SET @PublishedDBName = N'需要发布数据库名'SELECT @ReturnCode = 0begin transaction&-------------------------------------------------&-- Add REPL-Checkup category if not exist&-------------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-Checkup') & 1&&executemsdb.dbo.sp_add_category N'REPL-Checkup'&&-------------------------&-- Retrieve next JobID&-------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'Replication agents checkup')&if (@JobID is NULL)&BEGIN&&-----------------------------------------&&-- Add job Replication agentscheckup&&----------------------------------------&&print 'Add job Replicationagents checkup.'&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&&@job_name = N'Replication agents checkup',&&&&&&&&@enabled = 1,&&&&&&&&@start_step_id = 1,&&&&&&&&@notify_level_eventlog = 2,&&&&&&&&@notify_level_email = 0,&&&&&&&&@notify_level_netsend = 0,&&&&&&&&@notify_level_page = 0,&&&&&&&&@delete_level = 0,&&&&&&&&@description = N'Detects replication agents that are not logginghistory actively.',&&&&&&&&@category_name = N'REPL-Checkup',&&&&&&&&@owner_login_name = N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&------------------------&&-- Add step Run agent&&------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&&&&&@step_id = 1,&&&&&&&&&&&&@cmdexec_success_code = 0,&&&&&&&&&&&&@on_success_action = 1,&&&&&&&&&&&&@on_success_step_id = 0,&&&&&&&&&&&&@on_fail_action = 2,&&&&&&&&&&&&@on_fail_step_id = 0,&&&&&&&&&&&&@retry_attempts = 0,&&&&&&&&&&&&@retry_interval = 0,&&&&&&&&&&&&@os_run_priority = 0,&&&&&&&&&&&&@flags = 0,&&&&&&&&&&&&@step_name = N'Run agent.',&&&&&&&&&&&&@subsystem = N'TSQL',&&&&&&&&&&&&@command = N'sp_replication_agent_checkup @heartbeat_interval =10',&&&&&&&&&&&&@database_name = N'master'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-----------------&&-- Update jobs&&-----------------&&print '- Update jobs.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&------------------------------------&&-- Add Replication agentschedule&&------------------------------------&&print '- Add Replication agentschedule.'&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&&@name = N'Replication agent schedule.',&&&&&&&&&@enabled = 1,&&&&&&&&&@freq_type = 4,&&&&&&&&&@freq_interval = 1,&&&&&&&&&@freq_subday_type = 4,&&&&&&&&&@freq_subday_interval = 10,&&&&&&&&&@freq_relative_interval = 1,&&&&&&&&&@freq_recurrence_factor = 0,&&&&&&&&&@active_start_date = ,&&&&&&&&&@active_end_date = ,&&&&&&&&&@active_start_time = 223000,&&&&&&&&&@active_end_time = 235959&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&---------------------&&-- Add job server.&&---------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @ReturnCode &&INT------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SELECT @ReturnCode &= 0begin transaction&----------------------------------------------------&-- Add REPL-Alert Response category if notexist.&----------------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-Alert Response') & 1&&executemsdb.dbo.sp_add_category N'REPL-Alert Response'&&------------------------&-- Retrive next jobid&------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'Reinitialize subscriptions having data validationfailures')&if (@JobID is NULL)&BEGIN&&--------------------------------------------------------------------------&&-- Add job Reinitializesubscriptions having data validation failures.'&&--------------------------------------------------------------------------&&print 'Add job Reinitializesubscriptions having data validation failures.'&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&&@job_name = N'Reinitialize subscriptions having data validationfailures',&&&&&&&&@enabled = 1,&&&&&&&&@start_step_id = 1,&&&&&&&&@notify_level_eventlog = 0,&&&&&&&&@notify_level_email = 0,&&&&&&&&@notify_level_netsend = 0,&&&&&&&&@notify_level_page = 0,&&&&&&&&@delete_level = 0,&&&&&&&&@description = N'Reinitializes all subscriptions that have datavalidation failures.',&&&&&&&&@category_name = N'REPL-Alert Response',&&&&&&&&@owner_login_name = N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-------------------------&&-- Add step Run agent.&&-------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&&&&&@step_id = 1,&&&&&&&&&&&&@cmdexec_success_code = 0,&&&&&&&&&&&&@on_success_action = 1,&&&&&&&&&&&&@on_success_step_id = 0,&&&&&&&&&&&&@on_fail_action = 2,&&&&&&&&&&&&@on_fail_step_id = 0,&&&&&&&&&&&&@retry_attempts = 0,&&&&&&&&&&&&@retry_interval = 0,&&&&&&&&&&&&@os_run_priority = 0,&&&&&&&&&&&&@flags = 0,&&&&&&&&&&&&@step_name = N'Run agent.',&&&&&&&&&&&&@subsystem = N'TSQL',&&&&&&&&&&&&@command = N'exec dbo.sp_MSreinit_failed_subscriptions@failure_level = 1',&&&&&&&&&&&&@server = @PublisherName,&&&&&&&&&&&&@database_name = N'master'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-----------------&&-- Update job.&&-----------------&&print '- Update job.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&---------------------&&-- Add job server.&&---------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GOSET NOCOUNT ONuse masterGO----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'begin&----------------------&-- Add Distributor.&----------------------&print 'Add Distributor.'&exec sp_adddistributor&@distributor = @PublisherName, @password = N'', @from_scripting =1endGO------------------------------------------- Updating the agent profile defaults-----------------------------------------sp_MSupdate_agenttype_default @profile_id = 1GOsp_MSupdate_agenttype_default @profile_id = 2GOsp_MSupdate_agenttype_default @profile_id = 4GOsp_MSupdate_agenttype_default @profile_id = 6GOsp_MSupdate_agenttype_default @profile_id = 11GOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'begin&--------------------------------------&-- Adding the distribution database&--------------------------------------&print 'Add distribution database.'&exec sp_adddistributiondb&@database = N'distribution',&&&&&&@data_folder = N'D:\SQLServer\MSSQL\Data',&&&&&&@data_file = N'distribution.MDF',&&&&&&@data_file_size = 2,&&&&&&@log_folder = N'D:\SQLServer\MSSQL\Data',&&&&&&@log_file = N'distribution.LDF',&&&&&&@log_file_size = 0,&&&&&&@min_distretention = 0,&&&&&&@max_distretention = 72,&&&&&&@history_retention = 48,&&&&&&@security_mode = 0,&&&&&&@login = N'sa',&&&&&&@password = '',&&&&&&@from_scripting = 1endGOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @ReturnCode &&INT----------------------------- Initialize variable(s)---------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SELECT @ReturnCode &= 0begin transaction&-----------------------------------------------------------&-- Add 'REPL-Distribution Cleanup' category ifnot exist&-----------------------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-Distribution Cleanup') & 1&&executemsdb.dbo.sp_add_category N'REPL-Distribution Cleanup'&&-------------------------&-- Retrieve next JobID&-------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'Distribution clean up: distribution')&if (@JobID is NULL)&BEGIN&&print 'Add job Distributionclean up.'&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&&@job_name = N'Distribution clean up: distribution',&&&&&&&&@enabled = 1,&&&&&&&&@start_step_id = 1,&&&&&&&&@notify_level_eventlog = 0,&&&&&&&&@notify_level_email = 0,&&&&&&&&@notify_level_netsend = 0,&&&&&&&&@notify_level_page = 0,&&&&&&&&@delete_level = 0,&&&&&&&&@description = N'Removes replicated transactions from thedistribution database.',&&&&&&&&@category_name = N'REPL-Distribution Cleanup',&&&&&&&&@owner_login_name = N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&&&&&@step_id = 1,&&&&&&&&&&&&@cmdexec_success_code = 0,&&&&&&&&&&&&@on_success_action = 1,&&&&&&&&&&&&@on_success_step_id = 0,&&&&&&&&&&&&@on_fail_action = 2,&&&&&&&&&&&&@on_fail_step_id = 0,&&&&&&&&&&&&@retry_attempts = 0,&&&&&&&&&&&&@retry_interval = 0,&&&&&&&&&&&&@os_run_priority = 0,&&&&&&&&&&&&@flags = 0,&&&&&&&&&&&&@step_name = N'Run agent.',&&&&&&&&&&&&@subsystem = N'TSQL',&&&&&&&&&&&&@command = N'EXEC dbo.sp_MSdistribution_cleanup @min_distretention= 0, @max_distretention = 72',&&&&&&&&&&&&@server = @PublisherName,&&&&&&&&&&&&@database_name = N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&print '- Update job.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&print '- Add Replication agentschedule.'&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&&@name = N'Replication agent schedule.',&&&&&&&&&@enabled = 1,&&&&&&&&&@freq_type = 4,&&&&&&&&&@freq_interval = 1,&&&&&&&&&@freq_subday_type = 4,&&&&&&&&&@freq_subday_interval = 10,&&&&&&&&&@freq_relative_interval = 1,&&&&&&&&&@freq_recurrence_factor = 0,&&&&&&&&&@active_start_date = ,&&&&&&&&&@active_end_date = ,&&&&&&&&&@active_start_time = 500,&&&&&&&&&@active_end_time = 459&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GOSET NOCOUNT ON&----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @ReturnCode &&INT----------------------------- Initialize variable(s)---------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据名'SELECT @ReturnCode &= 0begin transaction&------------------------------------------------------&-- Add 'REPL-History Cleanup' category if notexist&------------------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-History Cleanup') & 1&&executemsdb.dbo.sp_add_category N'REPL-History Cleanup'&&-------------------------&-- Retrieve next JobID&-------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'Agent history clean up: distribution')&if (@JobID is NULL)&BEGIN&&-------------------------------------&&-- Add job Agent history cleanup.&&-------------------------------------&&print 'Add job Agent historyclean up.'&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&@job_name= N'Agent history clean up: distribution',&&&&&&&@enabled= 1,&&&&&&&@start_step_id= 1,&&&&&&&@notify_level_eventlog= 0,&&&&&&&@notify_level_email= 0,&&&&&&&@notify_level_netsend= 0,&&&&&&&@notify_level_page= 0,&&&&&&&@delete_level= 0,&&&&&&&@description= N'Removes replication agent history from the distributiondatabase.',&&&&&&&@category_name= N'REPL-History Cleanup',&&&&&&&@owner_login_name= N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-------------------------&&-- Add step Run agent.&&-------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 1,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 1,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 2,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Run agent.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'EXEC dbo.sp_MShistory_cleanup @history_retention = 48',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-----------------&&-- Update job.&&-----------------&&print '- Update job.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-------------------------------------&&-- Add Replication agentschedule.&&-------------------------------------&&print '- Add Replication agentschedule.'&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&@name= N'Replication agent schedule.',&&&&&&&&@enabled= 1,&&&&&&&&@freq_type= 4,&&&&&&&&@freq_interval= 1,&&&&&&&&@freq_subday_type= 4,&&&&&&&&@freq_subday_interval= 10,&&&&&&&&@freq_relative_interval= 1,&&&&&&&&@freq_recurrence_factor= 0,&&&&&&&&@active_start_date= ,&&&&&&&&@active_end_date= ,&&&&&&&&@active_start_time= 0,&&&&&&&&@active_end_time= 235959&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&---------------------&&-- Add job server.&&---------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GOSET NOCOUNT ON----------------------- declare section---------------------DECLARE @strDir&&nvarchar(128)DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)----------------------------- Initialize variable(s)---------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SET @strDir &&= N'\\' +@PublisherName + N'\Replication'begin&---------------------------------------&-- Adding the distribution publisher&---------------------------------------&print 'Add Distribution publisher.'&exec sp_adddistpublisher&@publisher = @PublisherName,&&&&@distribution_db= N'distribution',&&&&@security_mode= 1,&&&&@working_directory= @strDir,&&&&@trusted= N'false',&&&&@thirdparty_flag= 0endGOSET NOCOUNT ON&----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @JobName&&nvarchar(45)DECLARE @Command&&nvarchar(150)DECLARE @ReturnCode &&INT------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SET @JobName &&= N''+@PublisherName + '-Snapshot'SET @Command &&= N'-Publisher ['+ @PublisherName + '] -PublisherDB ['+ @PublishedDBName+']&-Distributor ['+&&&@PublisherName+ '] -Publication ['+ @PublishedDBName +'] -DistributorSecurityMode1 'SELECT @ReturnCode &= 0begin transaction&-----------------------------------------------&-- Add 'REPL-Snapshot' category if notexist&-----------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-Snapshot') & 1&&executemsdb.dbo.sp_add_category N'REPL-Snapshot'&-------------------------&-- Retrive next JobID&-------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N''+ @PublisherName + '-Snapshot')&if (@JobID is NULL)&BEGIN&&&&----------------------------------------------------&&-- Add'PublisherName-Snapshot'&&----------------------------------------------------&&print 'Add ' + @JobName&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&@job_name= @jobName,&&&&&&&@enabled= 1,&&&&&&&@start_step_id= 1,&&&&&&&@notify_level_eventlog= 0,&&&&&&&@notify_level_email= 0,&&&&&&&@notify_level_netsend= 0,&&&&&&&@notify_level_page= 0,&&&&&&&@delete_level= 0,&&&&&&&@description= N'No description available.',&&&&&&&@category_name= N'REPL-Snapshot',&&&&&&&@owner_login_name= N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&----------------------------------------------&&-- Add step Snapshot Agentstartup message.&&----------------------------------------------&&print '- Add step SnapshotAgent startup message.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 1,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 3,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 3,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Snapshot Agent startup message.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'sp_MSadd_snapshot_history @perfmon_increment =0,& @agent_id = 1, @runstatus = 1, @comments =''Starting agent.''',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&--------------------------&&-- Add step Run agent.&&--------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 2,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 1,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 3,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 10,&&&&&&&&@retry_interval= 1,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Run agent.',&&&&&&&&@subsystem= N'Snapshot',&&&&&&&&@command=&&&&&&&&@Command,&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&------------------------------------------------&&-- Add step Detect nonloggedagent shutdown.&&------------------------------------------------&&print '- Add step Detectnonlogged agent shutdown.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 3,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 2,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 2,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Detect nonlogged agent shutdown.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'sp_MSdetect_nonlogged_shutdown @subsystem = ''Snapshot'',@agent_id = 1',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&----------------------&&-- Update job step.&&----------------------&&print '- Update jobstep.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&--------------------------------------&&-- Add Replication agentschedule.&&--------------------------------------&&print '- Add Replication agentschedule.'&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&@name= N'Replication agent schedule.',&&&&&&&&@enabled= 1,&&&&&&&&@freq_type= 4,&&&&&&&&@freq_interval= 1,&&&&&&&&@freq_subday_type= 1,&&&&&&&&@freq_subday_interval= 0,&&&&&&&&@freq_relative_interval= 0,&&&&&&&&@freq_recurrence_factor= 0&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&----------------------&&-- Add job server.&&----------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @JobName&&nvarchar(60)DECLARE @Command&&nvarchar(180)DECLARE @ReturnCode &&INT------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SET @JobName &&= N'' +@PublisherName + '-LogReader'SET @Command &&= N'-Publisher ['+ @PublisherName + '] -PublisherDB&['+@PublishedDBName +'] -Distributor [' +&&&@PublisherName+ '] -DistributorSecurityMode 1& -Continuous-PollingInterval 30 -ReadBatchThreshold 20000'SELECT @ReturnCode &= 0begin transaction&&------------------------------------------------&-- Add 'REPL-LogReader' category if notexist&------------------------------------------------&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-LogReader') & 1&&executemsdb.dbo.sp_add_category N'REPL-LogReader'&--------------------------&-- Retrieve next JobId&--------------------------&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'' + @PublisherName + '-LogReader')&if (@JobID is NULL)&BEGIN&&&----------------------------------------------------------------------&&-- Add'PublisherName-LogReader'&&----------------------------------------------------------------------&&print 'Add ' + @JobName&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&@job_name= @JobName,&&&&&&&@enabled= 1,&&&&&&&@start_step_id= 1,&&&&&&&@notify_level_eventlog= 0,&&&&&&&@notify_level_email= 0,&&&&&&&@notify_level_netsend= 0,&&&&&&&@notify_level_page= 0,&&&&&&&@delete_level= 0,&&&&&&&@description= N'No description available.',&&&&&&&@category_name= N'REPL-LogReader',&&&&&&&@owner_login_name= N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&------------------------------------------------&&-- Add step Log Reader Agentstartup message.&&------------------------------------------------&&print '- Add step Log ReaderAgent startup message.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 1,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 3,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 3,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Log Reader Agent startup message.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'sp_MSadd_logreader_history @perfmon_increment = 0, @agent_id =1, @runstatus = 1, @comments = ''Starting agent.''',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&&&&&&&&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-------------------------&&-- Add step Run agent.&&-------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 2,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 1,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 3,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 10,&&&&&&&&@retry_interval= 1,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Run agent.',&&&&&&&&@subsystem= N'LogReader',&&&&&&&&@command= @Command,&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-----------------------------------------------&&-- Add step Detect nonloggedagent shutdown.&&-----------------------------------------------&&print '- Add step Detectnonlogged agentshutdown.'&&&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 3,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 2,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 2,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Detect nonlogged agent shutdown.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'sp_MSdetect_nonlogged_shutdown @subsystem = ''LogReader'',@agent_id = 1',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= N'distribution'&&&&&&&&&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&------------------&&-- Update job.&&------------------&&print '- Update job.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&@name= N'Replication agent schedule.',&&&&&&&&@enabled= 1,&&&&&&&&@freq_type= 64,&&&&&&&&@freq_interval= 0,&&&&&&&&@freq_subday_type= 0,&&&&&&&&@freq_subday_interval= 0,&&&&&&&&@freq_relative_interval= 0,&&&&&&&&@freq_recurrence_factor= 0,&&&&&&&&@active_start_date= ,&&&&&&&&@active_end_date= ,&&&&&&&&@active_start_time= 0,&&&&&&&&@active_end_time= 235959&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&----------------------&&-- Add job server.&&----------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GO&SET NOCOUNT ON&------------------------ Declare section----------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @JobID&&&BINARY(16)DECLARE @ReturnCode &&INT------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SELECT @ReturnCode &= 0begin transaction&if (select count(*) from msdb.dbo.syscategorieswhere name = N'REPL-Subscription Cleanup') & 1&&executemsdb.dbo.sp_add_category N'REPL-Subscription Cleanup'&&select @JobID = job_id from msdb.dbo.sysjobswhere (name = N'Expired subscription clean up')&if (@JobID is NULL)&BEGIN&&-------------------------------------------&&-- Add job Expired subscriptionclean up.&&-------------------------------------------&&print 'Add job Expiredsubscription clean up.'&&execute @ReturnCode =msdb.dbo.sp_add_job @job_id = @JobID OUTPUT,&&&&&&&@job_name= N'Expired subscription clean up',&&&&&&&@enabled= 1,&&&&&&&@start_step_id= 1,&&&&&&&@notify_level_eventlog= 0,&&&&&&&@notify_level_email= 0,&&&&&&&@notify_level_netsend= 0,&&&&&&&@notify_level_page= 0,&&&&&&&@delete_level= 0,&&&&&&&@description= N'Detects and removes expired subscriptions from publisheddatabases.',&&&&&&&@category_name= N'REPL-Subscription Cleanup',&&&&&&&@owner_login_name= N'sa'&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&----------------------------&&-- Add step Run agent.&&----------------------------&&print '- Add step Runagent.'&&execute @ReturnCode =msdb.dbo.sp_add_jobstep @job_id = @JobID ,&&&&&&&&@step_id= 1,&&&&&&&&@cmdexec_success_code= 0,&&&&&&&&@on_success_action= 1,&&&&&&&&@on_success_step_id= 0,&&&&&&&&@on_fail_action= 2,&&&&&&&&@on_fail_step_id= 0,&&&&&&&&@retry_attempts= 0,&&&&&&&&@retry_interval= 0,&&&&&&&&@os_run_priority= 0,&&&&&&&&@flags= 0,&&&&&&&&@step_name= N'Run agent.',&&&&&&&&@subsystem= N'TSQL',&&&&&&&&@command= N'EXEC dbo.sp_expired_subscription_cleanup',&&&&&&&&@server= @PublisherName,&&&&&&&&@database_name= @PublishedDBName&&&&&&&&&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&---------------------&&-- Update job.&&---------------------&&print '- Update job.'&&execute @ReturnCode =msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&---------------------------------------------&&-- Add job Replication agentschedule.&&---------------------------------------------&&print '- Add job Replicationagent schedule.'&&execute @ReturnCode =msdb.dbo.sp_add_jobschedule @job_id = @JobID,&&&&&&&&@name= N'Replication agent schedule.',&&&&&&&&@enabled= 1,&&&&&&&&@freq_type= 4,&&&&&&&&@freq_interval= 1,&&&&&&&&@freq_subday_type= 1,&&&&&&&&@freq_subday_interval= 1,&&&&&&&&@freq_relative_interval= 1,&&&&&&&&@freq_recurrence_factor= 0,&&&&&&&&@active_start_date= ,&&&&&&&&@active_end_date= ,&&&&&&&&@active_start_time= 10000,&&&&&&&&@active_end_time= 235959&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&&&&-------------------------&&-- Add job server.&&-------------------------&&print '- Add job server.'&&execute @ReturnCode =msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name =@PublisherName&&------------------&&-- Check errors&&------------------&&if (@@ERROR&& 0 OR @ReturnCode&& 0) goto QuitWithRollback&ENDcommit transactiongoto EndSaveQuitWithRollback:& if (@@TRANCOUNT & 0) rollbacktransactionEndSave:GO&use masterGOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)------------------------------- Initialize variable(s)-----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'begin&---------------------------------------&-- Enabling the replication database&---------------------------------------&print 'Enabling the replication database.'&exec sp_replicationdboption @dbname =@PublishedDBName, @optname = N'publish', @value = N'true'endGOuse [需要发布数据库名]GOSET NOCOUNT ON------------------------ Declare section----------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)DECLARE @PublicationDescr &nvarchar(100)DECLARE @SnapShotFolder &nvarchar(40)DECLARE @LogReaderJobName &nvarchar(60)DECLARE @SnapShotJobName &nvarchar(40)------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'SET @PublicationDescr &= N'Transactionalpublication of& database from Publisher ' +@PublisherName + '.'SET @SnapShotFolder &= N'\\' + @PublisherName +'\Replication'SET @LogReaderJobName &= N'' + @PublisherName +'-LogReader'SET @SnapShotJobName &= N'' + @PublisherName +'-Snapshot'begin&------------------------------------------&-- Adding the transactionalpublication&&&-----------------------------------------&print 'Add transactionalpublication.'&&exec sp_addpublication @publication =@PublishedDBName,&&&&@restricted= N'false',&&&&@sync_method= N'concurrent',&&&&@repl_freq= N'continuous',&&&&@description= @PublicationDescr,&&&&@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= @SnapShotFolder,&&&&@compress_snapshot= N'true',&&&&@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= @LogReaderJobName&---------------------------------&&--Add publication snapshot.&---------------------------------&print 'Add publication snapshot.'&exec sp_addpublication_snapshot @publication =@PublishedDBName,&&&&&@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= 223000,&&&&&@active_end_time_of_day= 0,&&&&&@snapshot_job_name= @SnapShotJobNameendGOSET NOCOUNT ON----------------------- Declare section---------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'begin&--------------------------------&-- Grant publication access.&--------------------------------&print 'Grant publication access.'&exec sp_grant_publication_access @publication =@PublishedDBName, @login = N'BUILTIN\Administrators'&-- exec sp_grant_publication_access @publication= @PublishedDBName, @login = N'GM\SQLAgent'&exec sp_grant_publication_access @publication =@PublishedDBName, @login = N'distributor_admin'&exec sp_grant_publication_access @publication =@PublishedDBName, @login = N'sa'endGOSET NOCOUNT ON------------------------ Declare section----------------------DECLARE @PublisherName&&nvarchar(32)DECLARE @PublishedDBName &nvarchar(32)------------------------------ Initialize variable(s)----------------------------SET @PublisherName &= N'' + @@SERVERNAME +''SET @PublishedDBName &= N'需要发布数据库名'begin&---------------------------------------&-- Adding the transactional articles&---------------------------------------&print 'Add transactional articles.'&--------------------&-- Template command&----------------------&exec sp_addarticle @publication =@PublishedDBName, @article =N'&TABLE_NAME&', @source_owner =N'dbo', @source_object =N'&TABLE_NAME&', @destination_table =N'&TABLE_NAME&', @type = N'logbased',@creation_script = null, @description = null, @pre_creation_cmd =N'drop', @schema_option = 0x00F3, @status = 16,@vertical_partition = N'false', @ins_cmd = N'CALLsp_MSins_&TABLE_NAME&', @del_cmd =N'CALL sp_MSdel_&TABLE_NAME&',@upd_cmd = N'MCALLsp_MSupd_&TABLE_NAME&', @filter =null, @sync_object = null, @auto_identity_range = N'false'&-------------------&-- Custom Tables&-------------------&&&--&&&&&&ADD HERE THE CUSTOM TABLES&&&&&&&&&------------------endGOprint 'Done.'所属分类:→&&&&作者:新浪博客&&&&时间: 0:00:00
All Right Reserved

我要回帖

更多关于 升级wp8.1正式版 的文章

 

随机推荐