When and Why we use Trigger ?

Posted by Amitabkabir under ASP.NET on 10/18/2008 | Views : 18400 | Status : [Member] | Replies : 10
Please let me describe when and why we use triggers?




Responses

Posted by: Muhsinathk on: 9/13/2012 [Member] Bronze | Points: 25

Up
0
Down
A trigger is a special kind of a store procedure that executes in response to certain action on the table like insertion, deletion or updation of data. It is a database object which is bound to a table and is executed automatically. You can't explicitly invoke triggers. The only way to do this is by performing the required action no the table that they are assigned to.

SQL Server 2000 has many types of triggers:

1. After Trigger
2. Multiple After Triggers
3.Instead Of Triggers
4. Mixing Triggers Type



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

Posted by: Muhsinathk on: 9/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Differences between storedprocedures and triggers
1. When you create a trigger you have to identify event and action of your trigger but when you create s.p you don't identify event and action

2.Trigger is run automatically if the event is occured but s.p don't run automatically but you have to run it manually

3. Within a trigger you can call specific s.p but within a sp you cannot call atrigger

4.Trigger execute implicitly whereas store procedure execute via procedure call from another block.

5.We can call a stored procedure from front end (.asp files, .aspx files, .ascx files etc.) but we can't call a trigger from these files.

6. Stored procedure can take the input parameters, but we can't pass the parameters as an input to a trigger.

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

Posted by: Hariinakoti on: 9/13/2012 [Member] Starter | Points: 25

Up
0
Down
Good Work Ms.Muhsinathk

Thanks & Regards
Hari

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

Posted by: Muhsinathk on: 9/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Thank you Mr.Hari

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

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Amitabkabir,
Please Mark as Answer if it helpful to you..That helps others who search the same...

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

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Amitabkabir,
Please Mark as Answer if it helpful to you..That helps others who search the same...

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

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Amitabkabir,
Please Mark as Answer if it helpful to you..That helps others who search the same...

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

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Friends,
if u got perfect answer then immediately Mark As Answer.It is very helpful to others

Thanks & Regards
Hari

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

Posted by: SheoNarayan on: 10/18/2008 [Administrator] HonoraryPlatinum

Up
0
Down
Hi Amit,

Please go through following article to know about triggers.

When to use triggers.

http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqlt.doc/sqltmst316.htm


Why to use triggers.

http://searchsqlserver.techtarget.com/generic/0,295582,sid87_gci1186123,00.html


Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Posted by: Meena_mehra on: 10/20/2008 [Member] Starter

Up
0
Down
1.When we want to insert data into multiple tables at same time.
2. when we want to write some constraints.
3. for security purpose we also use triggers

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

Login to post response