after insert触发器插入到azure表失败

b1uwtaje  于 2021-07-27  发布在  Java
关注(0)|答案(1)|浏览(386)

我在本地数据库的sql表上有一个非常简单的触发器。触发器如下所示:

ALTER TRIGGER [dbo].[trg_UpdateAzureDB]
ON  [dbo].[my_local_table]
AFTER INSERT,DELETE,UPDATE
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here
    INSERT INTO [myazuresvr].[myazuredb].[dbo].[myazuretable]([ImageId], [PimObjectId], [Relation], [ObjectType])
    SELECT * FROM inserted
END

因此,正如您所看到的,我要做的是将插入到azuresql数据库表中的数据推送。但是,当我插入到表中时,出现以下错误:

Msg 7399, Level 16, State 1, Procedure trg_UpdateAzureDB, Line 16 [Batch Start Line 10]
The OLE DB provider "SQLNCLI11" for linked server "myazuresvr" reported an error. One or more arguments were reported invalid by the provider.
Msg 7391, Level 16, State 2, Procedure trg_UpdateAzureDB, Line 16 [Batch Start Line 10]
The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "myazuresvr" was unable to begin a distributed transaction.

服务器被定义为本地服务器中的链接服务器。
最奇怪的是如果我这么做了:

INSERT INTO [myazuresvr].[myazuredb].[dbo].[myazuretable]([ImageId], [PimObjectId], [Relation], [ObjectType])
    SELECT * FROM [mylocaltable]

这很好。这似乎与我正在从触发器中插入azure表有关。。。
本地sql版本为12.0.6108 azure版本显示为12.0.2000
有什么建议吗?

wsewodh2

wsewodh21#

错误消息说它与分布式事务有关。将“启用分布式事务升级”标志设置为false应该可以工作。

相关问题