WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?

Answers were Sorted based on User's Feedback



WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / mallika

Triggers are the system generated events.
for example,
u have a table emp,in tat u can create a trigger which will
be activated if anyone performs any action such as insert,
update, delete on tat table.In tat trigger u can write code
which copies the updated info into another table.
we can provide security to the data by mentioning before
clause in tat trigger by which we can restrict the
modifications anyone can make to our table.

CREATE TRIGGER DelhiDel ON [Customers]
FOR DELETE
AS
IF (SELECT state FROM deleted) = ‘Delhi’
BEGIN
PRINT ‘Can not remove customers from Delhi’
PRINT ‘Transaction has been canceled’
ROOLBACK
END

Is This Answer Correct ?    46 Yes 5 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / sandeep

Triggers are also a stored procedure but it has some limits
and advantages over stored procedure.

first of all its limits. It cant accept or return values by
parameters whereas stored procedures do. It is called by
database server not by application or user.

It is generally treated as a constraint. It also make sure
the integrity of the data. We cud implement business rules
successfully by using triggers without writting a single
code in application. This is the main benifit of this
object we can change the business rule very easly from
database server when the actual business rules change that
means we dont want to edit and recompile the program soruce
code.

It will make problems in import process unless we switch
off the triggers.

There are 3 types of triggers in connection with insert,
update and delete statements

1. Before trigger
2. After Trigger
3. Instead of trigger

1. Before trigger fires before the manipulation of the data
happens by insert, update and delete statements. By using
this we cud do pre proces. ie updating other tables, pre
process of data, ..etc. After this actual manipulation
happens.

2. After triggers fires after the manipulation of the data
happens by insert, update and delete statements

3. Instead-of trigger. This trigger replaces the actual
manipulation statements. That means actual manipulation
statement wont work instead of this trigger will do the
manipulation work (statements in the trigger) by accepting
values from statement.

Is This Answer Correct ?    22 Yes 2 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / ashish tripathi

A trigger is a stored procedure that goes into effect when
you insert, delete, or update data in a table. You can use
triggers to perform a number of automatic actions, such as
cascading changes through related tables, enforcing column
restrictions, comparing the results of data modifications,
and maintaining the referential integrity of data across a
database.

Is This Answer Correct ?    12 Yes 5 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / talha

1 yes
2 no
3 no
4 no
5 no
6 no

Is This Answer Correct ?    6 Yes 4 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / subbarayudu

A Trigger is a block of code,fired whenever data in the underlying table is affected by any of the Data Manipulation Language (DML) statements -INSERT,UPDATE,OR DELETE.

whenever trigger fires,two special tables are created-
1.insert table 2.Delete table.

1.inserted table contains copy of all records that are insetred in the trigger table.
2.deleted table contains all records that have been deleted from trigger table.this table is used to refer old values.

Is This Answer Correct ?    2 Yes 0 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / sumesh

There are mainly two type trigger
1)After trigger
2)Insted of trriger

Baisicalt its like a stroeprocedure...

Is This Answer Correct ?    12 Yes 11 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / rami reddy.k

Triggers are the system generated events.
for example,
u have a table emp,in tat u can create a trigger which will
be activated if anyone performs any action such as insert,
update, delete on tat table.In tat trigger u can write code
which copies the updated info into another table.

A trigger is a stored procedure that goes into effect when
you insert, delete, or update data in a table. You can use
triggers to perform a number of automatic actions, such as
cascading changes through related tables, enforcing column
restrictions, comparing the results of data modifications,
and maintaining the referential integrity of data across a
database.

Is This Answer Correct ?    2 Yes 9 No

WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?..

Answer / kavithareddy

like as storeprocedure
it is userdefind function ther is no parameters

1)After trigger:

2)Insted of trriger

Is This Answer Correct ?    2 Yes 17 No

Post New Answer

More SQL Server Interview Questions

What is log cache in sql server?

0 Answers  


Do you know what are the restrictions that views have to follow?

0 Answers  


What is conditional split?

0 Answers  


What is the difference between NOROW and LOCKROW?

0 Answers   Accenture, Honeywell, Satyam,


Explain what are the events recorded in a transaction log?

0 Answers  






wat is the main diff between sql server 2000and sql server 2005

6 Answers   Jade Software,


Can a synonym name of a table be used instead of a table name in a select statement?

0 Answers  


What is recompile sql server?

0 Answers  


Explain what is the function of sql server agent windows service?

0 Answers  


What is clustered primary key?

0 Answers  


what is mean by crystal repoart? ahere we will mainly use that?

1 Answers  


How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?

2 Answers  


Categories