Which three actions should you perform in sequence?

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.)

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 StoredProcNamingPolicy

http://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.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


SQL123

SQL123

I thought the condition should be “Set the Field to @Name, Operator to NOT LIKE, and Value to ‘sp[_]%’. when the name is equal to sp_, it will violate the condition and so be prevented.

Stan

Stan

You need to ensure that users are unable to create stored procedures that begin with sp_.
So that means that you need to prevent if a new stored procedure is created that starts with sp_

Creating the condition with NOT LIKE is the way to go. Example below is the output of executing the CREATE PROCEDURE sp_test.

Policy ‘My_Naming_Policy’ has been violated by ‘SQLSERVER:\SQL\VM-SQL-01\DEFAULT\Databases\Temp\StoredProcedures\dbo.sp_test’.
This transaction will be rolled back.
Policy condition: ‘@Name NOT LIKE ‘sp_%”
Policy description: ”
Additional help: ” : ”
Statement: ‘CREATE PROCEDURE sp_test
AS
BEGIN
SELECT 1;
END’.

In your example from the url it reads:

In the following example, we’ll show how to create a policy that evaluates names of stored procedures and prevents their (re)naming based on a declared rule (e.g. we want the names of all stored procedures to start with the ‘ACME_’ string).

I REPEAT: we want the names of all stored procedures to start with the ‘ACME_’ string
THAT is the reason why here LIKE is used.

You should understand policy as, the name ‘sp_test’ meets the condition “sp_test does not start with sp_?” because this results to false, the evaluation mode On Change: prevent is fired.

… the name AUDIT_AggregateReport meets condition “AUDIT_AggregateReport starts with ACME_?” –> False –> prevent

Min

Min

if this question asking to prevent on creating Stored Proc name that start with sp_, yes it should be NOT LIKE.

Lloyd

Lloyd

Tested in lab and confirmed to be NOT LIKE.

ve

ve

I Tested too in lab and confirmed to be NOT LIKE.