Automation of Error Log Cycling

SQL Server version: 7.0 +

As a DBA you may want to automate process of
cycling an errorlog file.
This script includes the following:
* stored
procedure ‘usp_dba_cyclelog’ .
* It purges an errorlog file if it’s size
larger then value
specified by @filesize parameter (Bytes)
* sends e-mail
to notify a recipient and attaches the
information about existing errorlog
files.
* you can specify the errorlog file location with
@errorlog
parameter. If it is not specified the

HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQLServerMSSQLServerParametersSQL
Arg1
is
used.

* scheduled task to call usp_dba_cyclelog’ stored
procedure.

Before executing the cyclelog.sql script you need to replace

* string <recipient_name> with the semicolon-separated list of
the
recipients of the mail.
* string <size_in_Bytes> with the proper
value
* string <db_name> with the database name where
the
‘usp_dba_cyclelog’ stored procedure will be created

Make sure that
SQL Mail and SQL Server Agent are running.

I got the information on
xp_getfiledetails & xp_enumerrorlogs from Brian
Knight
‘Undocumented
T-SQL Tricks With Logs’. Please refer to this article
regarding the security
issue of using these stored procedures.

Download cyclelog.SQL

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles