How to compare data between two different database of two different providers? - mysql

We are planning to do a database Migration from MySql Server to MSSQL server; we have got some external tools and some internal tools to accomplish this. Now we need to have a process to validate the data between the MySql and MSSQL server after the Migration. We did a search and came across tablediff.exe. But it seems it can compare between only MSSQL databases. Not sure if we can use this tools by creating a linked server for MySql database (If so please let me know how to do that). If there is any other tools please suggest me.
Thanks in Advance,

I have achieved this using Linked server option of mssql server. I have created the linked server for my mysql database and used following query to achieve this
(select * from a
except select * openquery(LINKEDSERVER,'select * from a'))
Union
(select * openquery(LINKEDSERVER,'select * from a')
except
select * from a)
I'm not sure if this is a right way of doing this. But it did worked for us.

Related

Best way to synchronise data: MySQL -> SQL Server

I have a fairly straight way to copy selective data using SQL like so:
# Courses
DROP TABLE db_node.courses;
CREATE TABLE db_node.courses LIKE db_prod.course_sis;
INSERT INTO db_node.courses SELECT
*
FROM
db_prod.course_sis
WHERE
db_prod.course_sis.enabled = 1
AND db_prod.course_sis.hidden <> 1;
This is easy when I am on the same server with the same db, however I want to run this SQL to get put the final data on the SQL Server.
This isn't just a once off thing, it would need to be handled every hour or so. I am unable to change db's, one will always be MySQL and SQL Server because the data is used in a sharepoint app.
Thanks
There are several third-party tools to make this transition easier.
Check out SSMA here and here.
I'd also look at SQL Studio scheduled tasks to automate the process.

How can i export MS SQL into MySql table?

How can i export large tables from MS SQL into MySql table. Please note that the tables a large and.
I tried the mysql migration toolkit that is in MySql Workbench but i could not establish connectons to the SQL server
Please advise me on the best way to do this?
Thanks :)
One method of doing it (if it really is a lot of data and a lot of tables): creating a linked server in SQL Server and using it to push data into MySQL.
This article gives step-by-step instructions to create the linked server.
ANd then just run queries against your tables like so:
INSERT INTO OPENQUERY (<LINKED SERVER>, 'SELECT * FROM MySQL_Table')
SELECT * FROM dbo.SQL_Table

Is it possible to get information from different database with inner join having database in SQL and mySql?

I have my project A with mySql database and I have another project B with msSql. I have connected the database from A and fetched data from B. But now I need to use inner join for tables in A and B. Is it possible to do so with databases in the same server and different server? Any help will be appreciated.
Thanks in advance
Yes, it should be possible. First, you will need to link your MySQL server to your MS SQL Server.
See this reference. Secondly, you will probably need to use sub queries to select the correct columns and do the join on them;
SELECT *
FROM
(SELECT ms_column1, ms_column2 FROM MSSQLTABLE) AS mssql
JOIN
(SELECT my_column1, my_column2
FROM openquery(LINKED_SERVER, 'SELECT column1, column2 FROM MYSQLTABLE') AS mysql
ON mssql.ms_column1 = mysql.my_column1
Unfortunately untested.
Instead of making the two different databases communicate between themselves you can move the logic of the communication to the programming layer. For example using PDO and PHP you can connect to both databases, get the data, mix it and produce a result. You can create an abstraction layer of PHP classes that get information independently from A or B databases, and later you will not care anymore about it, as you will work with PHP objects not directly with databases.

how connect to mysql from oracle form

I would like to know can I connect to MySQL from Oracle forms? if yes would you put and example for me?
I suggest creating a database link in your Oracle DB that points at your MySQL DB. Then you can write queries such as this:
select * from oracle_table_1, mysql_table#mysql_link;
This document appears to have some helpful information on how to set all this up; apparently this isn't the simplest of tasks.

Select * from Database 1 and insert into database 2

I have 2 Database in my VB.net application. I am using 1st database for daily operations. I would like to send one of the table records to online database. How Can I do that? First database is MSSQL Online database is MYSQL. I have created connections already using MYSQL .net connector.
Any Help will be appreciated.
Regards
Have a look at using a Linked Server instance on SQL Server to write the data to MySQL using the four name notation.
SQL SERVER – Explanation and Example Four Part Name
SQL Server Four-part naming
Ok here is a rough set of steps you need to follow
Query the MSSQL database and retrieve the data you want. Storing it in a DataTable may be the best option starting off.
Loop through the DataTable rows and build an INSERT statement that will be run against the MYSQL database.
Execute the command against the MYSQL db.
This is the basics of what you need to do to get a simple working system. Also take a look at Transactions as a way to manage the rollback of data when something goes wrong.
I'm assuming this is a research project If you are planning on using this code in a production system then i would look into a different alternative such as uploading data files to a service attached to the MYSQL database. This would allow you to batch and retry an import when something goes wrong.