我在本地数据库中的 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
因此,正如您所看到的,我想要做的是将已插入到 Azure SQL 数据库表中的数据推送。但是,当我插入表时,出现以下错误:
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
有什么建议吗?