difference between stored procedure and trigger

Posted by Shanky11 under Sql Server on 12/22/2012 | Points: 10 | Views : 6268 | Status : [Member] | Replies : 3
what is the difference betwwn sp and trigger




Responses

Posted by: Sandeepmhatre on: 12/22/2012 [Member] Starter | Points: 25

Up
0
Down

http://sandeepmhatre.blogspot.com/2012/12/triggers-in-sql.html

Stored Procedure

http://sandeepmhatre.blogspot.com/2012/12/stored-procedure-table-name-in-sql.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/22/2012 [Member] Starter | Points: 25

Up
0
Down
hello,
Stored procedures are compiled collection of programs or SQL statements that live in the database. A stored procedure can access and modify data present in many tables. Also a stored procedure is not associated with any particular database object. But triggers are event-driven special procedures which are attached to a specific database object say a table. Stored procedures are not automatically run and they have to be called explicitly by the user. But triggers get executed when the particular event associated with the event gets fired. For example in case of a database having say 200 users and the last modified timestamp need to be updated every time the database is accessed and changed. To ensure this one may have a trigger in the insert or update event. So that whenever any insert or update event of the table gets fired the corresponding trigger gets activated and updates the last modified timestamp column or field with the current time. Thus the main difference between stored procedure and trigger is that in case of stored procedure the program logic is executed on the database server explicitly under eth user's request but in case of triggers event-driven procedures attached to database object namely table gets fired automatically when the event gets fired.

mark this if it help u

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/11/2013 [Member] Starter | Points: 25

Up
0
Down
Difference between Stored Procedure and Trigger:

1) Stored Procedure is predefined collection of sql statements.
2) Stored Procedure is Precompiled Execution.
3) Trigger is not Precompiled Exectution.
4) Trigger is not Reduce Client / Server Network Traffic.
5) Trigger Execute Automatic Execution Process. Stored Procedure is not automatic Procedure process.


sriram

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response