Showing posts with label Instead of trigger. Show all posts
Showing posts with label Instead of trigger. Show all posts

Thursday, 14 March 2013

Trigger in Sql Server

Written By:- Isha Malhotra
Our Website:-Tech Altum
Trigger
Triggers can be defined as an area of code Which executes in response of a particular action like insert, update, delete, Create, drop etc. Triggers executes automatically.

Type of triggers

1.       DML (Data Manipulation Language) Trigger
A DML trigger is Fired in response of DML statement like insert, update, delete etc.
Syntax:-
Create trigger trg_name on Table_name
For/after/instead of   Action (insert, update, delete)
As
Your statement…………………………

Type of DML Trigger:-
After /For Trigger
This trigger runs after insert, update and Delete command.
For example:-
Suppose I want to create tracking system for my table. As I used in my project that if any user delete any record from table then this record insert into the another table too, So that in future we can track that how many rows deleted in this table. In that case I used after delete trigger as shown following:-