DRAG DROP
You administer a Microsoft SQL Server 2012 server that has multiple databases.
You need to ensure that users are unable to create stored procedures that begin with sp_.
Which three actions should you perform in sequence? (To answer, move the appropriate actions
from the list of actions to the answer area and arrange them in the correct order.)
Answer: See the explanation
Explanation:
1) Create a Condition named StoredProcNamingConvention by using the Stored Procedure
facet that has a single expression. Set the Field to @Name, Operator to LIKE, and Value to ‘sp[_]%’.
2) Create a Policy named StoredProcNamingPolicy Set the Check condition to
StoredProcNamingConvention and Evaluation Mode to On Change: Prevent
3) Enable StoredProcNamingPolicyhttp://msdn.microsoft.com/en-us/library/bb510667.aspx
Policies are created and managed by using Management Studio. The process includes the following
steps:
1. Select a Policy-Based Management facet that contains the properties to be configured.
2. Define a condition that specifies the state of a management facet.
3. Define a policy that contains the condition, additional conditions that filter the target sets, and the
evaluation mode.
4. Check whether an instance of SQL Server is in compliance with the policy.
Evaluation modes
There are four evaluation modes, three of which can be automated:
On demand. This mode evaluates the policy when directly specified by the user.On change: prevent. This automated mode uses DDL triggers to prevent policy violations.
Important
If the nested triggers server configuration option is disabled, On change: prevent will not work
correctly. PolicyBased Management relies on DDL triggers to detect and roll back DDL operations that do not comply
with policies that use this evaluation mode. Removing the Policy-Based Management DDL triggers or
disabling nest triggers, will cause this evaluation mode to fail or perform unexpectedly.
On change: log only. This automated mode uses event notification to evaluate a policy when a
relevant change is made.
On schedule. This automated mode uses a SQL Server Agent job to periodically evaluate a policy.
This seems to be a wrong answer.
https://social.msdn.microsoft.com/Forums/expression/en-US/6222b41a-fd51-47bf-ad4c-ccf06aa39b8e/070462-enable-condition?forum=sqldocumentation
It is the wrong answer because sql server conditions are counter intuitive. I finally figured it out now after your link convinced me to dig deeper. A condition must be true. If the condition is false, the policy is broken. If you make a condition: sp names like sp_, that means all sp has to be named sp_. If you make one that doesn’t begin with sp_, the condition will be broken and the sp will be prevented. So to make sure you don’t make an sp names sp_, you to have a condition where sp names not like sp_. Then the condition is true and the policy has been observed and nothing will happen. It’s the exact opposite of the law as it relates to common people. Killing someone, smoking dope, robbing a house, making sp names like sp_. If you do those, you go to jail. Laws tell us what not to do. A condition is a regulation. It tells us what to do. Test drugs before selling, pay tariffs, maintain an ebitda ratio above 2, make sp names not like sp_. If you do that, you’re fine. If you don’t you go to jail. A condition is a regulation. Microsoft programmers are idiots.
6 – 5 – 1
6-5-1
6-5-1
Here is my result:
Use Not Like ‘SP[_]%’ and Prevent
Create Procedure SP_ Not Success
Create Procedure SPP_ Success
Use Like ‘SP[_]%’ and Prevent
Create Procedure SP_ Success
Create Procedure SPP_ Not Success
so the answer is 6-5-1