A
A
Alexander Fedorov2018-10-23 20:22:41
MySQL
Alexander Fedorov, 2018-10-23 20:22:41

Is it possible to link MSSQ and MySQL tables via LinkedServer by guid?

There are two SQL servers: one MSSQL, the second MySQL. The second is connected to the first as a LinkedServer.
There is a need to export data from MSSQL to MySQL with control over the presence of exported data on a remote server.
All requests through openquery.
In the usual case, we check that there is no data in the remote table through left join and is null

insert into OPENQUERY (MYSQL, 'select
    Id, ...
  FROM mysqltable')
select
    ms.Id, ...
from OPENQUERY (MYSQL, 'select * FROM mysqltable') my
  right join MSSQLTable ms on my.Id = ms.Id
where My.Id is null

If Id is int, then the connection is normal.
But our Id in MSSQL is guid. And MySQL has its own dances with storage of UUID in binary form.
In this regard, the question itself is: is it even possible to correctly save a guid from MSSQL to MySQL via LinkedServer so that it can be used to link two tables using openquery.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2018-10-23
@Pagliaccio

And if you cast id to varbinary?
Or vice versa in a mysql query, instead of (or together) with *, also converting a binary uuid into a text-like one?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question