Regarding triggers and SPs | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Regarding triggers and SPs

Hello Friends, I have one doubt regarding triggers and sps. This question asked by interviewer. Can we execute SPs using triggers or vice versa? if Yes, please give example.If no, please give reason. Please do the needful. Thanks in advance Regards,
Bharath
Hi,
Triggers are created on Table and on a DML statement thus it can not be created on SP nor you may , but when DML statement are execute from SP it cause trigger to fire ,you may call sp from triggers but it may cause error refer :
http://msdn2.microsoft.com/en-us/library/ms187844.aspx Regards Hemantgiri S. Goswami
[email protected]
"Humans don’t have Caliber to PASS TIME , Time it self Pass or Fail Humans" – by Hemantgiri S. Goswami

You can call SPs from Triggers as triggers are event based in table. but you can’t call these event based triggers from SPs —————————————-
http://dineshasanka.blogspot.com/

Like the peoples said, You cannot call triggers directly from SP since triggers are fired becaused of events. However, you can call SP from trigger. When you’re SP contains DML commands, you are INDIRECTLY raising the associated trigger. <br /><br />Good luck on your interview results <img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />.<br /><br />May the Almighty God bless us all!<br />www.empoweredinformation.com
What was your answer in this regard?
quote:Originally posted by knowledgebaseforbk Hello Friends, I have one doubt regarding triggers and sps. This question asked by interviewer. Can we execute SPs using triggers or vice versa? if Yes, please give example.If no, please give reason. Please do the needful. Thanks in advance Regards,
Bharath

Satya SKJ
Microsoft SQL Server MVP
Contributing Editor & Forums Moderator
http://www.SQL-Server-Performance.Com
This posting is provided �AS IS� with no rights for the sake of knowledge sharing.
This is how a stored procedure can be used to call a trigger externally:
http://www.sqlservercentral.com/columnists/bkelley/triggers_1.asp
Thank you for your wonderful links friends. Thank you all…

quote:Originally posted by knowledgebaseforbk Thank you for your wonderful links friends. Thank you all…
You didnt answer to Satya’s question
Also read about triggers and procedures in sql server help file for more informations Madhivanan Failing to plan is Planning to fail
]]>