Asynchronous Triggers in SQL Server 2005/2008(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 服务代理 队列.然后可以通过存储过程异步处理队列.
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 中的异步触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2005/2008 中的异步触发器
基础教程推荐
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
