无法插入链接服务器的标识列

Cannot insert into identity column of linked server

即使我将 IDENTITY_INSERT 设置为 ON 并指定列,在插入到链接服务器时仍然会出现错误。

直接在服务器上时:

CREATE TABLE InsertTest (
    PrimaryAutoKey int NOT NULL
        IDENTITY(1, 1) PRIMARY KEY,
    ID nvarchar(10) NOT NULL,
    Description nvarchar(50)
)

INSERT INTO InsertTest(ID, Description)
VALUES ('Test01', 'First record; key auto-assigned')

SET IDENTITY_INSERT InsertTest ON

INSERT INTO InsertTest(PrimaryAutoKey, ID, Description)
VALUES (10, 'Test10', 'Second record; key specified')

SELECT * FROM InsertTest
/*
PrimaryAutoKey ID         Description
-------------- ---------- --------------------------------------------------
1              Test01     First record; key auto-assigned
10             Test10     Second record; key specified
*/

到目前为止一切都很好。但是当我从将其作为链接服务器的远程服务器发出以下命令时

INSERT INTO [LinkedServer].[DB].[dbo].InsertTest(PrimaryAutoKey, ID, Description)
VALUES (3, 'Test03', 'Third record; key specified')

我收到错误:

OLE DB provider "MSOLEDBSQL" for linked server "LinkedServer" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
Msg 7344, Level 16, State 1, Line 10
The OLE DB provider "MSOLEDBSQL" for linked server "LinkedServer" could not INSERT INTO table "[LinkedServer].[DB].[dbo].[InsertTest]" because of column "PrimaryAutoKey". The user did not have permission to write to the column.

我正在使用 sa 上下文和 RPC IN/OUT 连接到链接服务器。

将整批发送到链接服务器并运行在那里。

例如

declare @sql nvarchar(max) = N'

INSERT INTO InsertTest(ID, Description)
VALUES (''Test01'', ''First record; key auto-assigned'')

SET IDENTITY_INSERT InsertTest ON

INSERT INTO InsertTest(PrimaryAutoKey, ID, Description)
VALUES (10, ''Test10'', ''Second record; key specified'')

'

exec (@sql) at LinkedServer