How to transfer data from one table to another on different servers

Asked

Viewed 685 times

0

I need to copy the records of a table that is in a Linked Mysql server to SQL Server, that is, transfer the records from one server to the other. Could someone tell me a way to perform this through a query?

  • Linked server between mysql and sql-server?

  • Yes, they are two servers and one uses mysql and what I am using sql-server

1 answer

1


Of mysql to the sql-server you can do so:

UPDATE tabela SET campo=A.campo FROM
(SELECT * FROM OPENQUERY(nome-linked-server,'Select * From tabela')) A
  INNER JOIN join tabela B on b.Id=a.Id

You must enter the link name in the function OPENQUERY, and do the joins. In the example I used the alias "A".

  • Actually I wanted an Insert, I expressed myself wrong in the question, sorry. But the link you sent from OPENQUERY helped me. Thank you Ricardo Pontual!

  • I get it, just change the update to an update: INSERT INTO tabela (campos) SELECT mesmos-campos FROM OPENQUERY(...)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.