Create Error Log Loop

Source: Internet
Author: User

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 executesSp_cycle_errorlogStored Procedure in the master database. This will create a new error log without having to restart SQL Server.

Sp_cycle_errorlog

Close the current error log file and cycle the error log extension number (like restarting the server ). The new error log contains the version and copyright information, and a line indicating that the new log has been created.


Note
When SQL Server is started, the current error log is renamed to errorlog.1, errorlog.1 to errorlog.2, errorlog.2 to errorlog.3, and so on. Sp_cycle_errorlog allows you to cyclically access error log files without stopping and starting the server.

Permission
The execution permission of sp_cycle_errorlog is limited to members of the SysAdmin fixed server role.

Example
The following example loops through SQL server error logs.

Copy code
Exec sp_cycle_errorlog;
Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.