programming4us
programming4us
DATABASE

SQL Server 2012 : Defining Policies (part 2) - Conditions

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
7/24/2014 4:28:53 AM

Conditions

Conditions are the second step in the chain and provide the logical connection between facet properties and policies. Most of the key policy design decisions are made while creating conditions.

To begin building a new condition, use either the Management → Policy Management → Conditions context menu and choose New Condition or Object Explorer Management → Policy Management → Facets → Database context menu.

You can open an existing condition by double-clicking the condition or by using the Property command in its context menu. A condition may have multiple expressions, but each condition is based on only one facet, so every property in all the expressions in a condition must belong to the same facet.

Condition expressions use facet properties in boolean expressions that can be evaluated as true or false. The expression consists of a facet property, a comparison operator (such as =, !=, in, not in, like, not like), and a value.

To construct a condition that tests a database's autoshrink property, the expression would use the database facet and the @AutoShrink property, as shown in Figure 4. In this case the full expression is:

Figure 4 This condition includes an expression that tests the Database Facet's @AutoShrink. The condition evaluates as True if @AutoShrink = False.

20.4
@AutoShrink = False

Best Practice
Think of condition expressions as positive statements. Instead of thinking, “No database should be set to autoshrink,” think “All databases should have autoshrink set to False.”

The ellipsis button under Field and Value opens the Advanced Edit dialog box, as shown in Figure 5. The Cell value is typically a property, function, or a literal value; however, it is possible to build more advanced expressions that reference DMV or system tables.

Figure 5 Use the Advanced Edit dialog to create each side of the expression. In this case it shows the left side of the AutoShrink expression.

20.5

A condition may include multiple expressions, in which case the AndOr column defines how they are evaluated.


Best Practice
In the entire policy design scheme, the only place that enables multiples is designing multiple expressions within a single condition. Therefore, if every expression should indeed be tested, encapsulating multiple expressions in a single condition can reduce the number of conditions and policies.

The open condition's description page may be used to record a description of the condition, and the dependent policies page lists the policies based on the condition. After the condition is created, it may be enforced by one or more policies. To programmatically view the created conditions, query the dbo.syspolicy_conditions view in the MSDB database:

select * from msdb.dbo.syspolicy_conditions
Note
To build advanced conditions that check factors other than the built-in facets, look into the executeSQL and executeWMI functions.
Other  
  •  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
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
    - Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
    - Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    programming4us programming4us
    programming4us
     
     
    programming4us