Question: Trigger vs. S.P.

Question: Trigger vs. S.P.

Post by Aaro » Tue, 25 Jul 2000 04:00:00



What is the difference between a trigger and a stored procedure
and when would I want to use one over the other?

 
 
 

Question: Trigger vs. S.P.

Post by Adrian Edmond » Tue, 25 Jul 2000 04:00:00


A trigger is a special type of stored procedure. You can't call it directly
but it can act whenever a table is updated, deleted or has a value inserted.

A stored procedure is a bunch of transact statements compiled once and
called lots.

You will generally use stored procedures for manipulating data into and out
of the database.

Triggers are used to perform additional tasks such as enforcing business
rules, checking for data validity above the normal checks and helping to
keep the database in order.

For example , if you wanted to notify the administrator whenever a table was
updated, that might be better in a trigger as changes could be made in more
than one stored procedures.

Adrian

P.S Please don't post in HTML. It wastes bandwidth


What is the difference between a trigger and a stored procedure
and when would I want to use one over the other?