syspolicy_purge_history Job – Should I delete this ?

Leave a comment (0) Go to comments

I have not created this job named "syspolicy_purge_history", who created / own this job ?

This job is created automatically when on SQL Server 2008 Policy Management is enabled.
Policy Management is a new feature introduced on SQL Server 2008 onwards.

What tables are being used to store Policy Management  evaluation results?

Once the Policy Management defined, the policy can be evaluated against targets to check for compliance. Each evaluation of compliance will be recorded in tables in system database msdb,

  • syspolicy_policy_execution_history_details_internal
  • syspolicy_policy_execution_history_internal
  • syspolicy_policy_category_subscriptions_internal

The evaluation condition is built on top of object facets, which is predefined by Microsoft.

What this JOB,’syspolicy_purge_history’, does internally ?


What is the Purpose of the job, syspolicy_purge_history ?

This job is being used to remove records in those tables to maintain so it does not pile up and take up space unnecessarily. It has three steps

It does what instance it is running in and then erases system health records.

Step 1 : 
The first step verifies if Policy Management is enabled. If yes, it will go to the second step
IF (msdb.dbo.fn_syspolicy_is_automation_enabled() != 1)
            RAISERROR(34022, 16, 1)

step 2
Deletes policy evaluation history prior to cutoff date, defined by HistoryRetentionInDays.
EXEC msdb.dbo.sp_syspolicy_purge_history

step 3
It works out what instance it is running in and then erases system health records.

if (‘$(ESCAPE_SQUOTE(INST))’ -eq ‘MSSQLSERVER’) {$a = ‘\DEFAULT’} ELSE {$a = ”};
(Get-Item SQLSERVER:\SQLPolicy\$(ESCAPE_NONE(SRVR))$a).EraseSystemHealthPhantomRecords()

EOF - syspolicy_purge_history Job – Should I delete this ?, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.