Policy-Based Management is a feature that is introduced with SQL Server 2008. It allows us to set the rules we want in our systems, to set our standards and to make our controls automatically. For example, we can create a policy for control purposes so that the names of our stored procedures do not start with a number or database recovery models are not simple.
Before you read this article, I recommend that you read “Checksum and TornPage Concepts in SQL Server” to understand the these concepts.
To comprehend Policy Based Management (PBM), you need to understand some concepts.
A feature that can be managed by PBM. For example, there is a facet called Database. And you can use this facet to create a policy that checks the page verify option of the database.
You can access all facets via SSMS as follows. To access the facet details, you must double-click on it.
Checks whether the sub-property of the related facets provide the specified condition.
Create a Policy
Let’s create a policy that checks whether the” page verify ” option of the databases is a not CHECKSUM.
Right click Policies tab as follows from the Management> Policy tab and click New Policy.
We give a name to Policy on the screen that appears. We need to create a condition from Check Condition.
We’re clicking on New Condition.
We give a name to the condition from the screen that appears.
We select Database facet from Facet section.
By clicking … in the Expression section, we select @PageVerify, which is the sub-feature of Database facet.
We select = from Operator and Checksum from Value.
Thus, if there is a database that has not Checksum page verify option, the policy will fail.
By selecting On Schedule from the Evaluation Mode, we select the interval at which the policy will be checked and then click the Enable check box.
If we choose On Demand, it only checks when we execute policy.
If you have a server-based condition, you can create a server-based condition from the server restriction section.
If you want it to be checked automatically at certain intervals, click New in the Schedule section and determine the frequency that the policy will check the condition. We set it up to work once every day at 12: 00: 000 PM.
We created our policy. We click Evaluate as below to run it manually.
I got a result as follows in my local. As you can see, the policy has failed due to page verify option of the KYTum database is not Checksum.
When we click on View, we can see why the policy is failed.
When you refresh the instance, a red color x sign appears on the left side of the instance, that looks like the letter. The reason for this is that we have a policy that is failed on the instance. When you see this mark, you must look at the defined policies and fulfill their requirements.
With Policy Based Management, you can check many things on SQL Server. And I think a professional database administrator should use this feature that SQL Server offers us. You can find more articles on Policy Based Management at the following links.
“How To Check Page Verify Option of Databases Using Policy Based Management”