3. Creating a database properties policy
first step in creating a new policy is to right-click Policies under
Policy Management and choose New Policy. You then enter a policy name
and either choose an existing condition or create a new condition.
In the example shown in figure 5,
we'll create a policy called Database Properties Policy and create a
new condition. We'll use the Database facet and specify that both
AutoClose and AutoShrink should be false.
Figure 5. After selecting a condition's facet, we build the expression.
After clicking OK, we're returned to the policy definition screen shown in figure 6.
Here we select Every Database for the condition's target. For the
evaluation mode, we'll choose On Schedule and create a new schedule for
Figure 6. When you're creating a policy, after choosing a condition, you select the condition target and evaluation mode.
Figure 7. SQL Server Management Studio includes visual aids to make policy
violations stand out. In this case, the AdventureWorks2008 database has
failed a policy.
this point, the policy is created and will run according to the defined
schedule. One of the really useful features of the new SQL Server
Management Studio is that it's aware of policy failures. As shown in figure 7,
any server and/or database that has failed a policy will be marked with
a red cross icon. In this example, the AdventureWorks2008 database is
set to AutoShrink and AutoClose, contrary to the policy we just created.
correct the policy failure, rather than manually setting these two
database properties we can simply right-click the database and choose
Polices > Evaluate to view the policy failure, and then click Apply
to force the server's properties to comply with the policy conditions.
Once created, policies can be easily exported, and doing so enables a number of important management functions.
4. Exporting policies
can be exported in one of two ways. First, you can simply right-click
an existing policy and choose Export Policy. The resulting dialog box
allows you to select a location in which to save the XML-based policy
other method is based on an instance facet. By right-clicking on a
registered SQL Server instance, you can choose Facets. The View Facets
window allows you to view the instance properties on a facet-by-facet
basis, but more important, you can choose the option Export Current
State as Policy.
shows the Server Performance facet of the BNE-SQL-PR-01\SALES instance.
By clicking the Export Current State as Policy button, we're able to
create a new policy file based on the Server Performance properties of
The importance of this
function can't be overstated; essentially, we're able to configure a
single server to be exactly how we want all servers to be configured,
and then create policies based on the individual facets. Doing so makes
the configuration of multiple servers very simple, a process we'll
8. The Export Current State as Policy button allows us to create a
policy file based on an instance's facet configuration.