为了提高SQL性能和安全性,2号给客户升级SQL 2008 SP4补丁,升级过程中一切顺利。但重启服务器后,发现SQL服务无法启动,事件日志引出此错误:

由于升级步骤'sqlagent100_msdb_upgrade.sql'遇到错误598(状态1,严重性25),因此数据库'master'的脚本级别升级失败。

wKioL1dfZETQcRTcAAHRd2uYqZE056.png-wh_50

尝试恢复模板MASTER数据库,修复安装,升级修复都无法解决,后在网上找方案,发现在SQL启动参数中加 ;-T902参数可以启动SQL,并且能成功登录SMSS,步骤如下:

Enable trace flag 902 on the instance of SQL Server 2008 R2. To do this, follow these steps:

Open SQL Server Configuration Manager.

In SQL Server Configuration Manager, click SQL Server Services.

Double-click the SQL Serverservice.

In the SQL Server Properties dialog box, click the Advanced tab.

On click the Advanced tab, locate the Startup Parameters item.

Add ;-T902 to the end of the existing string value, and then click OK.

Right-click the SQL Serverservice, and then click Start.

If the SQL Server Agent service is running, right-click the SQL Server Agent service, and then click Stop.

Open SQL Server Management Studio, and then connect to the instance of SQL Server 2008 R2.

Run the following statements:

EXEC sp_configure 'show advanced', 1; 

RECONFIGURE with override  ; 

EXEC sp_configure 'allow updates', 0; 

RECONFIGURE with override  ; 

EXEC sp_configure 'Agent XPs', 1; 

RECONFIGURE with override  ; 

GO


In SQL Server Configuration Manager, right-click the SQL Serverservice, and then click Stop.

Remove trace flag 902 on the instance of SQL Server 2008 R2. To do this, delete ;-T902 from the string value that you updated in step 1f.

Right-click the SQL Serverservice, and then click Start.

Right-click the SQL Server Agent service, and then click Start.

In SQL Server Management Studio, reconnect to the instance of SQL Server 2008 R2.

In Object Explorer, expand Management, right-click Data Collection, and then click Enable Data Collection.

Note If data collection is already enabled, the Enable Data Collection item is unavailable.


做完以上步骤后,再启动SQL服务,发现服务仍然异常,尝试再加 ;-T902参数并手工运行报错的sqlagent100_msdb_upgrade.sql脚本,发现运行结果有此报错:

对文件 "D:\SQLDATA\temp_MS_AgentSigningCertificate_database.mdf" 的目录查找失败,出现操作系统错误 2(系统找不到指定的文件。)。

发现D:\SQLDATA目录并不存在,于是手工建立SQLDATA目录,再运行脚本,成功完成。再在启动参数中删除;-T902 ,再重新启动服务即可。

wKioL1dfaK7SahxUAABm9Ss2mnU554.png-wh_50


也有人的问题略有不同,他操作后,引出了其它错误信息。

从事件里可以看到一个错误信息:

 

Could not allocate space for object 'dbo.#bulkpackage' in database 'tempdb'

 

这是由于 tempdb太小造成执行语句失败。

 

先用;-T902重启 SQL Server之后,把 tempdb文件改大。再删除 ;-T902。重启 SQL Server就行了。



------------------------------------

下面方法好像更简单:

启动 SQL Server 服务启跟踪标志902


 


一般使用命令: Net Start MSSQL$InstanceName /T902  如果是默认实例 Net Start MSSQLSERVER /T902



C:\Windows\system32>net start MSSQLSERVER /T902


The SQL Server (MSSQLSERVER) service is starting.


The SQL Server (MSSQLSERVER) service was started successfully.


转自:

http://www.cnblogs.com/kerrycode/p/4877910.html