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 maximum size per database for sql server express?
select top 5 * from emp order by newid() my question is , how this query get executed?
Wht is SQL Injection Attack ?
What are the ways available in sql server to execute sql statements?
What does the automatic recovery do?
Define msdb database?
What is transactional replication?
i have account table which consists of account name,card no and card no consists 16 digits now i want to retrieve the data if card no starts from 4 then it should print visa and if it starts from 5 then it should print master so plse help me to write simple query with out store procs .
What are the differences between decimal and float in ms sql server?
What is the preferred way to create a clustered and non-clustered index? Which index should you create first the clustered or non-clustered?
What is Covering Indexes? Plz explain with example
Join 3 tables (table1, table2 & table3) in a single query. Inner join should be applied for table1 & table 2 and left outer join for table1 & table3 where table2.dept is ABC