SQL SERVER – 2008 – Introduction to Policy Management – Enforcing Rules on SQL Server

I have previously written article about SQL SERVER Database Coding Standards and Guidelines Complete List Download. I just received a question from one of the blog reader is there any way we can just prevent violation of company policy. Well Policy Management can come in handy in this scenario.

If our company policy is to create all the Stored Procedure with prefix ‘usp’ that developers should be just prevented to create Stored Procedure with any other prefix. Let us see a small tutorial how to create conditions and policy which will prevent any future SP to be created with any other prefix.

Let us first create the conditions which defines that name of the database object should start with ‘usp’.

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy1

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy2s

Now create policy for all the Stored Procedure of the database and assign previously created a condition of naming convention to all the Stored Procedure of the database.

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy3

Make sure that the Policy is enabled.

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy4s

Now try to create Stored Procedure with incorrect names. It will not let you create it, but will create an error.

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy5

If you try to create Stored Procedure prefixed with ‘usp’ it will create it successfully.

SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server policy6

Policy Management is a very detailed subject and I will write more tutorial about this subject in future.

Reference : Pinal Dave (https://blog.sqlauthority.com)

Policy Management, SQL Coding Standards, SQL Scripts, SQL Server
Previous Post
SQL SERVER – 2008 – Step By Step Installation Guide With Images
Next Post
SQLAuthority News – 600 Article and Over 3 Million Readers

Related Posts

Leave a Reply