从触发器调用链接服务器 [英] Calling linked server from trigger

查看:311
本文介绍了从触发器调用链接服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器A中创建了而不是触发器,在其中我调用了一个过程,该过程又在链接服务器(服务器B)中调用了其他过程。



触发器(A)->过程(A)->过程(B)



但是,触发器执行时引发以下错误:


链接服务器 xxx的OLE DB提供程序 SQLNCLI11返回消息合作伙伴事务管理器已禁用其对远程/网络事务。。
消息7391,级别16,状态2,行1
由于链接服务器 xxx的OLE DB访问接口 SQLNCLI11无法开始分布式事务,因此无法执行该操作。


当我这样做时:过程(A)->过程(B)可以正常工作。可能是什么原因?



我该如何解决?分布式查询与链接服务器查询是否不同?

解决方案

如果在触发器中使用链接服务器,则需要使用DTC(不建议使用)因为它的运行状况不佳,如果有任何连接问题,您的交易将会中止)





您的过程(A)可以填充一些队列表,然后某些计划任务可以读取该队列表并运行过程B。





使用复制或CDC(更改数据捕获)+计划任务在远程服务器上触发过程B





使用本地服务代理


I've created instead of trigger in server A, in which I call a procedure, which in turn calls other procedure in linked server (server B).

Trigger(A) -> Procedure (A) -> Procedure (B)

But, when trigger executes it throws following error:

OLE DB provider "SQLNCLI11" for linked server "xxx" returned message "The partner transaction manager has disabled its support for remote/network transactions.". Msg 7391, Level 16, State 2, Line 1 The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "xxx" was unable to begin a distributed transaction.

When I do this: Procedure (A) -> Procedure (B) it works perfectly. What can be the reason?

How can I fix this? Is distributed query differ from Linked server query?

解决方案

You need to use DTC if you use linked servers within a trigger (not recommended as it's not performing well and your transaction will be aborted if there are any connection issues)

or

your Procedure (A) may populate some queue table, and then some scheduled task may read that queue table and run Procedure B.

or

use Replication or CDC (change data capture) + scheduled task to trigger Procedure B on remote server

or

use Local Service Broker

这篇关于从触发器调用链接服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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