Twitter

Follow SQLQuill on Twitter

Subscribe

MN Pass

TSQL Tip O’ the Week – 8/9/11 – DDL Triggers for Extra Protection

This weeks tip:

Add extra protection to your databases by adding a DDL trigger that will prevent users from deleting your databases.

Why?

In the last year, five times a user deleted the wrong database by mistake in SQL Server Management Studio – each time they thought they were connected to their local machine, but they were really connect to a shared development environment.  If we would have had these triggers on our shared environments, we wouldn’t have wasted anytime restoring the databases.

Here’s a great article from Chriss K on MSDN with code showing how easy it is to add this extra layer of protection.

- Code Example to first LOG then prevent SQL Database from being deleted

Here’s the video from the post, but the code is in the article – note it is really easy:

Note – If you need to delete the database, you can simply disable the trigger with one line of code – the disable trigger statement.

Here are some related posts from the intraweb:

Previous Tips O’ the Week

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>