MS SQL Server 另一个触发器之后的触发器
我想在 MS SQL Server 中创建触发器,该触发器将在完成另一个触发器后调用。首先调用的触发器是插入触发器。是否可以?
I would like to create trigger in MS SQL Server that would be call after finishing another trigger. This trigger that is called first is insert trigger. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。
但棘手的部分是跟踪它们的执行顺序。强烈建议使用相同类型的多个触发器仅当它们完全独立时,因此可以按任何顺序执行。对于您的情况,最好在单个触发器中使用多个存储过程调用。以后你会感谢自己的。
有关该主题的更多信息,请参阅 SO 中的上一个问题:
SQL Server 触发器 - 执行顺序
Yes, it is.
But the tricky part is to track the order they are executed. It is strongly advised to use multiple triggers of the same type only if they are fully independent and hence could be executed in any order. In your case, better use multiple stored procedure calls in single trigger. You'll thank yourself later.
For more information on the subject, see previous question in SO:
SQL Server triggers - order of execution
是的,这是可能的。您最多可以嵌套 32 层触发器。
如果您想要更多嵌套,则可以使用 CTE(大约 100 级嵌套)。
Yes it is possible. You can do nesting of trigger up to 32 level.
If you want more nesting then you can use CTE (about 100 level of nesting).