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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you explain important index characteristics?

520


What are the benefits and tasks of object explorer? : sql server management studio

607


What does the on delete cascade option do?

546


If a user does not have permission to a table, but has permission to a view created on it, will he be able to view the data in table?

552


What are the new security features added in sql server 2012? : sql server security

532






What happens if null values are involved in string operations?

552


How to implement service broker?

521


How to change a login name in ms sql server?

556


explain different types of joins? : Sql server database administration

529


What is stored in the mssqlsystemresource database? : sql server database administration

587


List out the difference between union and union all in sql server?

517


Can we use trigger new in before insert?

514


What is row_number () and partition by in sql server?

519


How to declare a cursor with "declare ... Cursor" in ms sql server?

565


You have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem?

564