SQL Server 触发器 - 执行顺序 [英] SQL Server triggers - order of execution

查看:56
本文介绍了SQL Server 触发器 - 执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道 SQL Server 如何确定触发器(相同类型,即触发器之前)的执行顺序.有什么方法可以改变它,以便我可以指定我想要的顺序.如果没有,为什么不呢.

Does anyone know how SQL Server determines the order triggers (of same type, i.e. before triggers) are executed. And is there any way of changing this so that I can specify the order I want. If not, why not.

谢谢.

推荐答案

使用 SetTriggerOrder 没问题,但如果你的代码依赖于特定的执行顺序,为什么不把你所有的触发器都包装到存储过程中,并让第一个调用第二个,第二个调用第三个,以此类推

Using SetTriggerOrder is fine, but if your code depends on a specific sequence of execution, why not wrap all your triggers into stored procedures, and have the first one call the second, the second call the third, etc.

然后您只需在触发器中执行第一个.

Then you simply have the first one execute in the trigger.

未来的人会很感激他们不必在系统表中挖掘来确定自定义执行顺序.

Someone in the future will be grateful that they didn't have to dig around in a system table to determine a custom execution sequence.

这篇关于SQL Server 触发器 - 执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆