Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
Explain Triggers in Sql Server..?

Posted On: 01/11/2012 08:32:50

"A Trigger is a Database object just like a stored procedure or we can say it is a special kind of Stored Procedure which fires when an event occurs in a database.".

Difference between Stored Procedure and trigger: 

Triggers fire implicitly while Stored Procedures fire explicitly.

Type of Triggers:


There are two types of Triggers:

  1. DDL Trigger
  2. DML trigger

DDl Triggers:

They fire in response to DDL (Data Definition Language) command events that start with Create, Alter and Drop. Like Create_table, Create_view, drop_table, Drop_view and Alter_table.

Code of DDL Trigger:

create trigger saftey

on database

for

create_table,alter_table,drop_table

as

print'you can not create ,drop and alter table in this database'

rollback;

DML Triggers:

They fire in response to DML (Data Manipulation Language) command events that start with with Insert, Update and Delete. Like insert_table, Update_view and Delete_table.

Code of DML Trigger:

create trigger deep

on emp

MOST VIEWED QUESTION:
 
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us