Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Delete a Job Step Log

Delete a Job Step Log

 

This topic describes how to delete a SQL Server Agent job step log.

To delete a SQL Server Agent job step log

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.

  2. Expand SQL Server Agent, expand Jobs, right-click the job you want to modify, and then click Properties.

  3. In the Job Properties dialog box, delete the selected job step.

Arrow icon used with Back to Top linkBookmark link 'Top' is broken in topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}'. Rebuilding the topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}' may solve the problem.

To delete a SQL Server Agent job step log

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. 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).

Arrow icon used with Back to Top linkBookmark link 'Top' is broken in topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}'. Rebuilding the topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}' may solve the problem.

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)

Arrow icon used with Back to Top linkBookmark link 'Top' is broken in topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}'. Rebuilding the topic '{"project_id":"7d6ffa79-2ddc-4606-b774-a6a5d46784cd","entity_id":"ee20c6cd-0258-4550-bdb0-71e86a0fb330","entity_type":"Article","locale":"en-US"}' may solve the problem.

Community Additions

ADD
Show:
© 2015 Microsoft