如何在链接服务器上将数据从mssql更新到mysql

mkshixfv  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(335)

找不到链接服务器“mylinkedserver”返回消息“行”的ole db提供程序“msdasql”进行更新。自上次读取后,某些值可能已更改。“。

Msg 7343, Level 16, State 4, Line 1
The OLE DB provider "MSDASQL" for linked server "MYLINKEDSERVER" could not UPDATE table "[MSDASQL]".

行集正在使用乐观并发,并且在上次获取或重新同步包含行之后,列的值已更改。

DECLARE @Counter nvarchar(1024),
        @TSQL varchar(8000)

SET @Counter = 0

WHILE (@Counter <=(select Top 1 ID from mydb.dbo.tbl1 order by ID desc))

BEGIN

    set nocount on

    IF EXISTS(select Top 1 ID from mydb.dbo.tbl1 where ID = @Counter)

    BEGIN

        SELECT  @TSQL   = 'UPDATE OPENQUERY(MYLINKEDSERVER,''select * from mydb2.tbl2 where tbl1_id is not null and tbl1_id= ' + @Counter + ''')' + 'set employees = ' + CAST((select t.employees from mydb.dbo.tbl1 as t where t.ID = @Counter) as nvarchar)

        EXEC (@TSQL)
        SELECT @Counter=@Counter+1
    END

    ELSE BEGIN

        SELECT @Counter=@Counter+1

    END

END
lnxxn5zx

lnxxn5zx1#

odbc驱动程序高级选项。标记为“仅向前不缓存结果…”。。。返回匹配行上的lfag。。。

相关问题