Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
44umss
Starting Member
2 Posts |
Posted - 2012-08-15 : 08:28:54
|
| Hello everybody,In an interview i've been asked this question.According to my understanding triggers cannot be fire programmatically/manually, it only fires when an insert/update/delete happens on that table.Please Correct me if I am wrong |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-08-15 : 08:41:02
|
| You are right - triggers cannot be "called" manually like you can invoke a function or a stored proc. However, triggers can get invoked recursively and there can be nested triggers - see this page and in particular the sections on nested triggers and recursive triggers: http://msdn.microsoft.com/en-us/library/ms189799.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-15 : 10:08:32
|
| the actions done inside a trigger can cause invocation of another trigger------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
44umss
Starting Member
2 Posts |
Posted - 2012-08-15 : 12:49:36
|
| Thank you so much sunitabeck for the url, "Nested Triggers" cleared the topicand Thanks visakh16 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-15 : 12:58:57
|
| Nested Triggers is calling same trigger again and again ie performing same action recusively inside trigger for which trigger was written for. It depends on Nested Triggers setting at server/db level.The other scenario which I explained was case where one trigger logic causing invocation of other trigger on same or different object------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-08-15 : 14:34:30
|
quote: Originally posted by visakh16 Nested Triggers is calling same trigger again and again ie performing same action recusively inside trigger for which trigger was written for. It depends on Nested Triggers setting at server/db level.The other scenario which I explained was case where one trigger logic causing invocation of other trigger on same or different object------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
I thought it was the other way around - i.e., a nested trigger is when one trigger updates a different table that invokes the trigger on that table. And recursive trigger is when a trigger updates the same table, which causes the trigger to be invoked again.Of course you can have indirect recursion with nesting and recursion interleaved - i.e. when a nested trigger changes the data in the first table resulting in a recursive call to the first trigger. |
 |
|
|
|
|
|