Skip to content

Latest commit

 

History

History
70 lines (48 loc) · 2.16 KB

sp-cycle-agent-errorlog-transact-sql.md

File metadata and controls

70 lines (48 loc) · 2.16 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_cycle_agent_errorlog (Transact-SQL)
Closes the current SQL Server Agent error log file, and cycles the SQL Server Agent error log extension numbers.
markingmyname
maghan
randolphwest
07/05/2024
sql
system-objects
reference
sp_cycle_agent_errorlog
sp_cycle_agent_errorlog_TSQL
sp_cycle_agent_errorlog
TSQL

sp_cycle_agent_errorlog (Transact-SQL)

[!INCLUDE SQL Server]

Closes the current [!INCLUDE ssNoVersion] Agent error log file and cycles the [!INCLUDE ssNoVersion] Agent error log extension numbers just like a server restart. The new [!INCLUDE ssNoVersion] Agent error log contains a line indicating that the new log was created.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_cycle_agent_errorlog
[ ; ]

Arguments

None.

Return code values

0 (success) or 1 (failure).

Result set

None.

Remarks

Every time [!INCLUDE ssNoVersion] Agent is started, the current [!INCLUDE ssNoVersion] Agent error log is renamed to SQLAgent.1; SQLAgent.1 becomes SQLAgent.2, SQLAgent.2 becomes SQLAgent.3, and so on. sp_cycle_agent_errorlog enables you to cycle the error log files without stopping and starting the server.

This stored procedure must be run from the msdb database.

Permissions

Execute permissions for sp_cycle_agent_errorlog are restricted to members of the sysadmin fixed server role.

Examples

The following example cycles the [!INCLUDE ssNoVersion] Agent error log.

USE msdb;
GO

EXEC dbo.sp_cycle_agent_errorlog;
GO

Related content