PrepAway - Latest Free Exam Questions & Answers

Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 server that has multiple databases.
You need to ensure that users are unableto 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.)

Build List and Reorder:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:

Reference: 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 canbe 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. Policy-Based 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 disablingnest
triggers, will cause this evaluation mode to fail or perform unexpectedly.
On change: log only. This automated mode uses eventnotification 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.

8 Comments on “Which three actions should you perform in sequence?

  1. Testee says:

    The first solution-Part is wrong.

    The Condition must be @Name NOT LIKE ‘sp[_]%’

    You can test it by creating the condition and an policy that enforces the condition “On Change: Prevent”

    You get an error like this when creating an sp_-Stored Procedure

    Condition: ‘@Name NOT LIKE ‘sp[_]%”

    ‘CREATE PROCEDURE sp_test
    as BEGIN
    print @@version;
    END’.

    Message 3609, Level 16, Status 1, Procedure sp_syspolicy_dispatch_event, Zeile 65
    The transaction ended in the trigger. The batch has been aborted.

    The policy enforces the condition.
    Therefore you have to define the condition in the way you want the object to be.

    in this case:
    the Name should not begin with sp_
    define that as condition and the policy enforce the condition then




    1



    0
  2. Joe says:

    Sorry om kumar you are wrong. I have also tested it. The answer which is given is ABSOLUTELY INCORRECT.

    The correct answer is, as Testee stated, NOT LIKE.

    Below is the dump from the policy violation, in case there is any further doubt:

    Policy ‘StoredProcNamingPolicy’ has been violated by ‘SQLSERVER:\SQL\Joe-2008VM\DEFAULT\Databases\AdventureWorks2012\StoredProcedures\Person.sp_getPeople’.
    This transaction will be rolled back.
    Policy condition: ‘@Name NOT LIKE ‘sp[_]%”
    Policy description: ”
    Additional help: ” : ”
    Statement: ‘create procedure Person.sp_getPeople
    as
    select * from Person.Person;’.
    Msg 3609, Level 16, State 1, Procedure sp_syspolicy_dispatch_event, Line 65
    The transaction ended in the trigger. The batch has been aborted.




    1



    0
  3. Yommy O. says:

    Testee is very right; @name NOT LIKE ‘sp[_]%’

    When you create a stored procedure with any name starting with ‘sp_’ you get the following error:

    Policy ‘StoredProcNamingPolicy’ has been violated by ‘SQLSERVER:\SQL\MYSQLSERVER\DEFAULT\Databases\master\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
    print @@version;
    END
    ‘.
    Msg 3609, Level 16, State 1, Procedure sp_syspolicy_dispatch_event, Line 65
    The transaction ended in the trigger. The batch has been aborted.




    1



    0
  4. Donk says:

    Answer given is correct:

    You need to create a condition which checks if the stored procedure name is LIKE ‘sp[_]%’, then you need to create a policy that PREVENTS, since you want to prevent the creation of stored procedures beginning with SP.

    Created and checked it.




    0



    1
  5. Adrian says:

    Error log below proves it.

    Donk , you say you’ve tested it. Can we have the error log ?

    100% you need to use NOT LIKE (I know it’s weird but that is correct)

    Policy ‘test’ has been violated by ‘SQLSERVER:\SQL\DATA-SERVER\EVOSERVER\Databases\Reports\StoredProcedures\dbo.sp_ar_test’.
    This transaction will be rolled back.
    Policy condition: ‘@Name NOT LIKE ‘sp_%”
    Policy description: ”
    Additional help: ” : ”
    Statement: ‘create procedure sp_ar_test
    as

    select 1’.
    Msg 3609, Level 16, State 1, Procedure sp_syspolicy_dispatch_event, Line 65
    The transaction ended in the trigger. The batch has been aborted.




    1



    0

Leave a Reply