Difference between Triggers and Stored Procedure
Answers were Sorted based on User's Feedback
Answer / ram
Stored Procedures are called by the programmer wherever it
wants to fire but triggers fired automatically when
insert,delete,update occured. And triggers can be
implemented to tables & views only where as s.p used in the
database independently
Is This Answer Correct ? | 135 Yes | 13 No |
Answer / pankaj arya
To use stored procedure you have to make a call to that
procedure but Triggers fired automatically when an event is
occurred on the table associated with that Trigger like add,
insert or delete.
Is This Answer Correct ? | 108 Yes | 7 No |
Answer / bed singh
1. Triggers can only be implemented on tables or views but
Stored Procedure in independent code that can be specific
to database.
2. Triggers are automatically run but stored procedures are
not automatically run and they have to be called explicitly
by the user.
3. we can write a stored procedure within a trigger but
cannot write a trigger within a stored procedure.
4. Trigger is attached to table or view and is fired only
when an INSERT, UPDATE, and/or DELETE occurs, while a
stored procedure executes at any time when it is called.
Is This Answer Correct ? | 75 Yes | 9 No |
Answer / gopal chauhan
Stored Procedure can give one output paramenter,but
Triggers can not give any output parameter
Is This Answer Correct ? | 61 Yes | 20 No |
Answer / madhu prakash p
sp and trigger are both predefined set of sql statements
we can pass the arguments for sp but we cant pass the
arguments for triggers.
trigger will fire implicitly, when ever relavent action
performed by the user on the tables where the triggers are
placed.
But in the stored procedures u must call explicitly.
Is This Answer Correct ? | 43 Yes | 9 No |
Answer / ghanshyam vrema
1. SP may Return a value but Trigger Not,
2. In SP you can pass parameter But in trigger you can't
3. we explicitly call the Sp when Trigger are implicitly
fired
4. you can write a sp in Trigger but in a Trigger you cant
write SP.
5. Trigger written on an individual Table or View where SP
is written for an Database
Is This Answer Correct ? | 75 Yes | 43 No |
Answer / avdhesh yadav
1. Stored Procedure may Return a value but Trigger Not,
2. In Stored Procedure you can pass parameter But in
trigger you can't
3. we explicitly call the Stored Procedure when Trigger are
implicitly
fired
4. you can write a Stored Procedure in Trigger but in a
Trigger you cant
write Stored Procedure.
5. Trigger written on an individual Table or View where
Stored Procedure
is written for an Database
Is This Answer Correct ? | 29 Yes | 7 No |
Answer / pramod bansode
1> For executing Sp we have to call Stored Procedure. But in
case of Trigger it is call whenever there is an action taken
on table or column(Insert, Update ,Delete).
2> From SP we pass Values But from Trigger we cant.
3> stored procedure returns value but trigger cannot returns
value.
4> For SP we have to compile. for Trigger no need to compile.
5> we return SP in Trigger but Trigger can not be in SP.
Is This Answer Correct ? | 18 Yes | 8 No |
Answer / shilpa
triggers are fired automatically when any event ocours like
update ,delete ,insert on a table
whereas sp is set of sql statements its not related to
single table but its can have many sql satements that can
be used in many tables to update, delete and insert .
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / naveen jindal
trigger fired implicitely that is when ever events like
insert/update/delete commands.
Where as stored procedure is not fired implicitely. when
ever we call then only the stored procedure fire.
Is This Answer Correct ? | 6 Yes | 1 No |
what is the output for this query select * from employee where 1=1;
What are different types of raid levels?
What is exporting utility?
What are the triggers in sql?
How many types of the database links?
How to create function without parameter in sql server?
1.how to find the dead lock in sql server? 2.How to fine the memory leaks in sql server? 3.suppose transaction log file increasing what action will take ?
Explain powershell included in sql server 2008?
When would you prefer to have a minimum number of indexes?
How do I view a stored procedure in sql server?
What are functions
What is the basic functions for master, msdb, tempdb databases?