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 an extended Stored Procedure?
How to fetch records from a One to Many relationship table. eg: wanna get details of all orders for a specific customer. (do not want repeatation of master table records for child table records)
What do we need queues in sql service broker?
What are the diifferences between the ms sql server vs mysql?
What is openrowset sql server?
A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query?
What is SQL Profiler what is the use of it?
2 Answers 247Customer, Steria,
How to transfer an existing table from one schema to another schema in ms sql server?
tell me the disaster recovery plan
how to get rank of diffrent student in same table based on newly inserted row in sql server2008
Where is trigger in sql server?
What are temporal tables in sql server 2016?