SQL Server: cycle the error log and the Agent error log
Close the current error log and start a new one with sp_cycle_errorlog and sp_cycle_agent_errorlog.
The SQL Server error log and the SQL Server Agent error log can grow very large and become hard to read. Two stored procedures "cycle" them: the current log is closed and a new one is started, without restarting the service.
SQL Server error log
EXEC sp_cycle_errorlog ;
GO
SQL Server Agent error log
USE msdb ;
GO
EXEC dbo.sp_cycle_agent_errorlog ;
GO
Notes
- The current log becomes archive no. 1 (
ERRORLOG.1), existing archives are shifted and the oldest one is deleted according to the number of retained logs (6 by default for SQL Server). sp_cycle_errorlogrequires membership in thesysadminfixed server role.- Cycling is often scheduled in an Agent job (for example weekly or monthly) to keep files at a reasonable size.