Sql触发器是同步的还是异步的? [英] Are Sql Triggers synchronous or asynchronous?

查看:238
本文介绍了Sql触发器是同步的还是异步的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张上面有插入触发器的表。如果我从一个存储过程中的一条插入语句中向该表中插入6000条记录,该存储过程会在插入触发器完成之前返回吗?

I have a table that has an insert trigger on it. If I insert in 6000 records into this table in one insert statement from a stored procedure, will the stored procedure return before the insert trigger completes?

只是为了确保我我想得对,因为只有1个插入语句,对触发器应该只调用一次(我知道'被叫'不是正确的单词),对吧?

Just to make sure that I'm thinking correctly, the trigger should only be called (i know 'called' isn't the right word) once because there was only 1 insert statement, right?

我的主要问题是:即使触发器尚未完成,存储过程也会完成吗?

My main question is: will the sproc finish even if the trigger hasn't completed?

推荐答案

您的插入触发器将为整个插入语句。这就是为什么使用 insertted 临时表查看实际插入的内容,而不仅仅是选择最新的单个记录或类似内容的原因。

Your insert trigger will run once for the entire insert statement. This is why it is important to use the inserted temporary table to see what has actually been inserted, and not just select the most recent single record, or something like that.

我刚刚测试了插入和更新触发器,实际上,它们被sql server视为插入的一部分。在触发器完成之前,该过程不会完成。

I just tested an insert and update trigger and indeed, they are considered part of the insert by sql server. the process will not finish until the trigger finishes.

这篇关于Sql触发器是同步的还是异步的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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