SQL Server 2012 : Defining Policies (part 3) - Creating Policies

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Creating Policies

If the facet property is the fact and the condition the brain, the policy is the muscle. Policies define how and where the condition is applied and enforced.

You can create a new policy using the New Policy menu item in Object Explorer's Management → Policy Management → Policies and then selecting the New Policy option from the context menu. Alternatively, you can go to the File menu, browse to the New submenu, and then select Policy from the list. The Create New Policy dialog, as shown in Figure 6, has a general page and a description page.

Figure 6 Viewing a Policy. This policy enforces the AutoShrink condition for every database on demand.


You can open an existing policy by double-clicking the policy or by using the Property command in its context menu.

The general page has four key selections. The first is the condition; a policy may check only a single condition. The ellipsis opens the condition.

The second selection, targets, defines which objects will be tested. The options vary depending on the type of object the facets apply to.

Evaluation mode is the third key selection. There are four Evaluation modes for a policy:

  • On Demand: The policy is evaluated only manually. There's no schedule, automatic testing, or enforcement.
  • On Schedule: The policy is evaluated and any violations are logged but not corrected.
  • On Change Log Only: The policy is evaluated when the facet is changed, and violations are logged.
  • On Change Prevent: The policy is evaluated when the facet is changed, and violations are rolled back. This action rolls back a violation only after the action has occurred; meaning a large transaction that violates a policy may take a long time to roll back changes.

Every facet may be set to On Demand or On Schedule, but On Change is limited. PBM relies on DDL eventing to do CheckOnChange, and not all objects support DDL eventing. The following query reports which Execution modes are available for which facets:

SELECT name as Facet, 
Max(CASE WHEN execution_mode & 0 = 0 Then 1 else 0 End)
as ‘On Demand',
Max(CASE WHEN execution_mode & 4 = 4 Then 1 else 0 End)
as ‘On Schedule',
Max(CASE WHEN execution_mode & 2 = 2 Then 1 else 0 End)
as ‘On Change Log Only',
Max(CASE WHEN execution_mode & 1 = 1 Then 1 else 0 End)
as ‘On Change Prevent'
FROM msdb.dbo.syspolicy_management_facets

Result is shown in Table 1:

Table 1 Facet Listing

c20tnt001 c20tnt001 c20tnt001 c20tnt001

The fourth key selection on the general page is Server Restriction. You can use this option to define the target servers based on criteria.

PBM generates DDL triggers that enforce the policy and roll back DDL operations that don't comply with the policy. Don't manually delete or edit these DDL triggers. Also, servers that use PBM must have nested triggers enabled.
PBM also generates agent jobs for policy automation. They shouldn't be deleted either.

To programmatically view the created policies, query the dbo.syspolicy_policies view in the MSDB database:

select * from msdb.dbo.syspolicy_policies

You can export policies to XML and import them using the Policy context menu.

  •  SQL Server 2012 : Validating Server Configuration (part 2) - Evaluate the Policy, Using the Central Management Server
  •  SQL Server 2012 : Validating Server Configuration (part 1) - The Need for a Policy, Create Policy on a Local Server
  •  SQL Server 2012 : Encryption (part 2) - Certificate-Based Encryption, Transparent Data Encryption
  •  SQL Server 2012 : Encryption (part 1) - Encryption Primer, Password-Based Encryption
  •  SQL Server 2012 : Auditing in SQL Server (part 3) - Database Audit Specification Object, User-Defined Audit Event
  •  SQL Server 2012 : Auditing in SQL Server (part 2) - Server Audit Specification Object
  •  SQL Server 2012 : Auditing in SQL Server (part 1) - Auditing Objects, Server Audit Object
  •  SQL Server 2012 : Reordering Nodes within the Hierarchy - The GetReparentedValue Method,Transplanting Subtrees
  •  SQL Server 2012 : Querying Hierarchical Tables - The IsDescendantOf Method
  •  Protecting SQL Server Data : Obfuscation Methods (part 4) - Truncation,Encoding, Aggregation
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us