In this step by step SQL Tutorial I will show you how to create policy condition which is part of SQL Server policy based management For the purpose of this tutorial I will use SQL Server 2012.
Other Versions of SQL Server:
- SQL Server 2012
- This blog post has been written using SQL Server 2012
- SQL Server 2008 / R2
- The examples we used should work in SQL Server 2008 and R2
- SQL Server 2005
- Policy Based Management is not available in SQL Server 2005.
Who is it for?
- People who would like to learn basics of creating policy condition
- Those who are preparing for Microsoft certifications and need to cover this topic.
Prior knowledge. If you are new to SQL or new to certain SQL Server features you might find links below useful when working with this tutorial:
- Our Example of policy
- Creating new condition
Our Example of policy
We continue using our example of issue with cast date and cast datetime when different login language is used and to prevent unexpected results I decided to build new policy that will ensure our SQL Server logins have language set to English.
Before we can set up new policy we need to create new condition and in next section we describe how to do it.
Creating new condition
In order to create new condition expand Policy Management folder. Right Click Condition and click new condition (see below)
In my case I will call the condition CheckLoginLanguage and I will use Login facet with Language Field (facet property) and set expression (condition) to = 'English' and click ok.
I have just created condition that will check if Login Language is set to English.
NOTE: You can add multiple expressions and use And/Or that can help you to create more complex conditions.
You can see below that new condition has been created.
In next article I will show you how to create new policy using this condition.