Delete a Job Step Log
Applies To: SQL Server 2016 Preview
This topic describes how to delete a SQL Server Agent job step log.
Before you begin:
To delete a SQL Server Agent job step log, using:
When job steps are deleted their output log is automatically deleted.
Unless you are a member of the sysadmin fixed server role, you can only modify jobs that you own.
In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
Expand SQL Server Agent, expand Jobs, right-click the job you want to modify, and then click Properties.
In the Job Properties dialog box, delete the selected job step.
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute.
-- 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
For more information, see sp_delete_jobsteplog (Transact-SQL).
Use the DeleteJobStepLogs methods of the Job class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell. For more information, seeSQL Server Management Objects (SMO).
-- Uses PowerShell to delete all job step log files that have ID values larger than 5. $srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)") $jb = $srv.JobServer.Jobs["Test Job"] $jb.DeleteJobStepLogs(5)