sp_delete_jobsteplog (Transact-SQL)
Removes all SQL Server Agent job step logs that are specified with the arguments. Use this stored procedure to maintain the sysjobstepslogs table in the msdb database.
By default, members of the sysadmin fixed server role can execute this stored procedure. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:
SQLAgentUserRole
SQLAgentReaderRole
SQLAgentOperatorRole
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
Only members of sysadmin can delete a job step log that is owned by another user.
A. Removing all job step logs from a job
The following example removes all job step logs for the job Weekly Sales Data Backup.
USE msdb ;
GO
EXEC dbo.sp_delete_jobsteplog
@job_name = N'Weekly Sales Data Backup';
GO
B. Removing the job step log for a particular job step
The following example removes the job step log for step 2 in the job Weekly Sales Data Backup.
USE msdb ;
GO
EXEC dbo.sp_delete_jobsteplog
@job_name = N'Weekly Sales Data Backup',
@step_id = 2;
GO
C. Removing all job step logs based on age and size
The following example removes all job steps logs that are older than noon October 25, 2005 and larger than 100 megabytes (MB) from the job Weekly Sales Data Backup.
USE msdb ;
GO
EXEC dbo.sp_delete_jobsteplog
@job_name = N'Weekly Sales Data Backup',
@older_than = '10/25/2005 12:00:00',
@larger_than = 104857600;
GO