Export (0) Print
Expand All

Clear the Job History Log

This topic describes how to delete the contents of the Microsoft SQL Server Agent job history log in SQL Server 2012 by using SQL Server Management Studio, Transact-SQL, or SQL Server Management Objects.

In This Topic

Security

For detailed information, see Implement SQL Server Agent Security.

Arrow icon used with Back to Top link [Top]

To clear the job history 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, and then expand Jobs.

  3. Right-click a job and click View history.

  4. In the Log File Viewer, select the job for which you want to clear history, and then do one of the following:

    • Click Delete, and then click Delete all history in the Delete History dialog. You can delete all job history or only history that is older than a specified date. If you want to remove all job history, click Delete all history. If you only want to remove older job history logs, click Delete history before, and then specify a date.

    • Click Job status if you want to clear the history log of a multiserver job. Click Job, click a job name, and then click View Remote Job History.

  5. Click Delete.

Arrow icon used with Back to Top link [Top]

To clear the job history 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.

    -- example removes the history for a job named NightlyBackups.
    USE msdb ;
    GO
    
    EXEC dbo.sp_purge_jobhistory
        @job_name = N'NightlyBackups' ;
    GO
    

Arrow icon used with Back to Top link [Top]

To clear the job history log

Use the PurgeJobHistory method of the JobServer class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell. For more information, see SQL Server Management Objects (SMO).

Arrow icon used with Back to Top link [Top]

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft