3. Creating a database properties policy
The
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.
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
Nightly 11PM.
At
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.
To
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
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
file.
The
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.
Figure 8
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
this server.
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
cover next.