Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

  Whenever SQL Server is restarted, it creates a new error log. If theserver stays up for a while, this can make for a very large error log. I create a job that runs on a daily or weekly basis that executes the sp_cycle_errorlog stored procedure in the master database. This will create a new error log without having to restart SQL Server.

  

sp_cycle_errorlog

关闭当前的错误日志文件,并循环错误日志扩展编号(就像重新启动服务器)。新错误日志包含版本和版权信息,以及表明新日志已创建的一行。


注释
每次启动 SQL Server 时,都会将当前错误日志重命名为 errorlog.
1;errorlog.1 变为 errorlog.2,errorlog.2 变为 errorlog.3,依次类推。sp_cycle_errorlog 可使您循环访问错误日志文件,而不必停止和启动服务器。

权限
sp_cycle_errorlog 的执行许可权限仅限于 sysadmin 固定服务器角色的成员。

示例
以下示例将循环 SQL Server 错误日志。

复制代码
EXEC sp_cycle_errorlog ;
GO

  

posted on 2011-03-30 10:13  Fanr_Zh  阅读(290)  评论(0编辑  收藏  举报