SQL Server 2005/2008中的异步触发器 [英] Asynchronous Triggers in SQL Server 2005/2008

查看:126
本文介绍了SQL Server 2005/2008中的异步触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些触发器,可以将大量数据操纵并插入到变更跟踪表中,以便在每次插入,更新和删除时进行审核。

I have triggers that manipulate and insert a lot of data into a Change tracking table for audit purposes on every insert, update and delete.

此触发器可以很好地完成工作,通过使用它,我们能够根据每笔交易的业务需求记录所需的旧值/新值。

This trigger does its job very well, by using it we are able to log the desired oldvalues/newvalues as per the business requirements for every transaction.

但是在某些情况下,源表中的列很多,事务最多可能需要30秒才能完成,这是不可接受的。

However in some cases where the source table has a lot columns, it can take up to 30 seconds for the transaction to complete which is unacceptable.

是否可以使触发器异步运行?任何示例。

推荐答案

您不能使触发器异步运行,但是可以使触发器同步地将消息发送到 SQL Service Broker 队列。然后可以通过存储过程异步处理队列。

You can't make the trigger run asynchronously, but you could have the trigger synchronously send a message to a SQL Service Broker queue. The queue can then be processed asynchronously by a stored procedure.

这篇关于SQL Server 2005/2008中的异步触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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