What are SQL Server Triggers?

SQL Server Triggers is said to be one of the most ignored objects. These are attached to a table and are used to execute a batch of SQL code whenever a specific event occurs. A trigger is what the name suggests. It is activated whenever specific event happens such as inserting, updating or deleting SQL command against a specific table.

Why triggers are a big help?

SQL Server Triggers can do many things. Before, users after updating tables have to perform some actions after the update. He has to "hard code" the extra SQL into his application. This would mean that a user wanting to change the code later down the track needs the updated version of the application. The task becomes both time-consuming and annoying.

What are the benefits of SQL Server Triggers?

Since triggers appear in the database as a separate entity from other database application, it gives a number of benefits.
First, triggers standardize actions performed by more than one application program. Because the coding action is stored in the database for future use, applications have only to fire the trigger to get the same results again and again.

Second, triggers create efficiency. When a trigger is created, it is checked if the syntax is correct and then later stored in the system tables. Eventually, when there is an application that fires a trigger, then it is compiled from the system table and then executed in the virtual memory of the server. After the first execution, a copy of the trigger is in the memory, which makes the next execution of the same procedure happen instantly.

A user who is in the field of database design and development can benefit from SQL Server Triggers. There are many books and links available online that could be of help to him.

Categories: News