Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends.

I want to know about triggers.

Which Place it is used and is it only for table .

can we apply triggers on SP
Posted

Definition:
A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server. DML triggers execute when a user tries to modify data through a data manipulation language (DML) event. DML events are INSERT, UPDATE, or DELETE statements on a table or view.

You can use triggers in a situation where you need to perform any calculation at the time of insert, update and delete operation.
For eg: In case of delete if you want add the same value in another table to maintain history.

Triggers can not be invoked manually, it will execute automatically.

You can not use triggers on SP.

For more details please refer below links:

http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]

http://www.databasejournal.com/features/mssql/article.php/3837541/DML-Triggers-in-SQL-Server-2008.htm[^]

Regards
Praveen
 
Share this answer
 
Comments
Prasad_Kulkarni 26-Apr-12 4:36am    
Good explanation! +5!
Arul R Ece 26-Apr-12 4:50am    
Thankn u praveen..nice
Be friendly to Google and try to search there first ,
here are few links to learn :
http://www.kodyaz.com/articles/sql-trigger-example-in-sql-server-2008.aspx[^]

http://www.go4expert.com/forums/showthread.php?t=15510[^]

and many more from google .
hope this helps
 
Share this answer
 
Comments
Prasad_Kulkarni 26-Apr-12 4:36am    
+5!
member60 26-Apr-12 5:14am    
thank you Prasad
Please refer following threads:

A good article on CP:
Triggers -- Sql Server[^]

This might help you more:
SQL triggers[^]
An Introduction to Triggers -- Part I[^]
Exploring SQL Server Triggers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900