TechNet
Export (0) Print
Expand All

Delete a Job Step Log

 

Applies To: SQL Server 2016 Preview

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

Limitations and Restrictions

When job steps are deleted their output log is automatically deleted.

Security

Permissions

Unless you are a member of the sysadmin fixed server role, you can only modify jobs that you own.

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.

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

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)

Community Additions

ADD
Show:
© 2016 Microsoft