title: How to update data from mssql to mysql on linked server
body: <blockquote>
    <p>OLE DB provider "MSDASQL" for linked server "MYLINKEDSERVER" returned
    message "Row cannot be located for updating. Some values may have been
    changed since it was last read.".</p>
  </blockquote>
  
  <pre><code>Msg 7343, Level 16, State 4, Line 1
  The OLE DB provider "MSDASQL" for linked server "MYLINKEDSERVER" could not UPDATE table "[MSDASQL]". 
  </code></pre>
  
  <p>The rowset was using optimistic concurrency and the value of a column has been changed after the containing row was last fetched or resynchronized.</p>
  
  <pre><code>DECLARE @Counter nvarchar(1024),
          @TSQL varchar(8000)
  
  SET @Counter = 0
  
  WHILE (@Counter &lt;=(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
  </code></pre>