Migrate mysql tables to existing sql database - mysql

How can I migrate mysql tables to an already existing sql database.I have tried using sql server migration assistant for mysql tool, but it migrates entire database to a new database in sql server.Is it possible to transfer mysql tables to existing sql database?
Please help

If you have MySQL workbench and you only need the table structures you can select the tables that you need then:
Right Click > Copy to clipboard > Create Statement
Then past these into your new database an excecute

you can create a linked server the target system; this way you can import the tables selecting the data into the new tables on sql server.
if you already have the DDL migrated then you can fill the tables otherwise you can create the tables while copying the data.
with little scripting you can have the SQL code needed to copy the data ready in minutes.
there are many SO posts about interacting with MySQL from SQL-Server:
Can't create linked server - sql server and mysql
SELECT * FROM Linked MySQL server
Do I have to use OpenQuery to query a MySQL Linked Server from SQL Server?

Have you tried the Import/Export Wizard from within SQL Server Management Studio - it's essentially SSIS (an ETL tool) behind the scenes. It allows you to select specific objects, do transforms and such. I'd expect you'd be able to use a standard ODBC driver.
MSSQLTips has an article that seems relevant:
https://www.mssqltips.com/sqlservertutorial/2205/mysql-to-sql-server-data-migration/

Related

How to create a Table with same structure from MySQL in SQL server Using Store Procedure or SSIS Functionality

I have some list of Tables to be created in SQL Server with the same structure as they are currently present in MySQL DB.
Tools which i can use are SSIS , SQL Server (T-SQL) But haven't found a solution still

Creating a SQL server view from multiple DB engines?

I have a SQL server DB, a Oracle DB, a MySQL DB. I have a way to join the tables from each DB. How would be the best way to create this view? I have just started SSIS project that pulls the tables from the DBs and creates the view I want, but is there a way to grab the data from each engine in the view in real-time\dynamic?
Thr best way to do that is to create a linked server for each instance (Oracle, MySQL) on sql server without the need to copy data.
And then you can create a view that join the tables between instances.
For more information, you can follow these articles:
Create Linked Servers (SQL Server Database Engine)
Create a linked server to MySQL from SQL Server
Creating a SQL Server 2014 Linked Server for an Oracle 11g Database
SQL Server Linked Server Example Query

SSIS linked to a mySQL server

in SQL server it's possible to link a mySQL server into msSQL and query it using SSMS for example. I want to try this and use SSIS to do some transformations and store all the data on this mySQL database.
\I read that there a several ways to link to mySQL into the msSQL server. OLE DB, mySQL ODBC etc etc.
2 questions:
Are there any limitations i might run into when i will use a combination of SSIS and mySQL instead of msSQL?
When i link a mySQL database into msSQL and i write a query in SSMS, do i write the queries in mySQL language or msSQL language. For example the difference in TOP and LIMIT
I have worked with a linked MySQL Server from SQL Server in the past and ran into some issues.
Querying MySQL from SSMS (SQL Server)
Once you have created a linked server you would imagine you should be able to use the four-part name and query the tables in MySQL but it doesnt allow you. for example you cannot do something like...
Select * from MySqlServer.DbName.Schema.TableName
For some reason it throws an error. So the question whether I can use T-SQL in SSMS to query a Linked MySQL Server? Nope, unfortunately not.
But alternatively Microsoft recommends using OPENQUERY to execute queries to a linked server.
When using OPENQUERY, SQL Server does not try to parse the query, it just sends it to the linked server as it is. which means you can/should be able to write MySQL in SSMS using OPENQUERY and it will work.
Using SSIS with MySQL
Even though SSIS is Microsoft's tool that comes with SQL Server but it is a proper ETL tool which can read data from multiple sources and send data to many types of destination.
Once you have used the appropriate driver to connect to MySQL and ported data in SSIS package , its really not relevant anymore, where the data came from? you would have access to all the SSIS tools and you should be able to use them as if the data was coming from a flat file, SQL Server or Excel sheet etc.
By using Linked Server in MSSQL you can also connect to mySql. for that you need to download ODBC drivers. and then you have to create new dsn and while creating dsn you have to insert mySql server's details. then you can further search regarding how to create Linked server on SQL SERVER. This option is very easy and Totally free. You can use OPEN QUERY FOR inserting, updating, deleting and also get the data out from mySQL.

I need to create a table in MYSQL from MSSQL and insert/update data

I have a MS SQL 2008 server with a database and need to create a table in MYSQL from a table/data in MS SQL. The mysql database has been linked and I have full access to the database. Can I do this using openquery?
OPENQUERY doesn't let you run DDL statements against remote databases. To the best of my knowledge, MySQL doesn't have an equivalent method of interacting with other RDBMS's.
You can however do this from SQL Server using the Import/Export Wizard to copy your table to MySQL. You may need to install MyOleDB or a similar driver to connect to MySQL.
Please see http://msdn.microsoft.com/en-us/library/ms140052%28v=sql.105%29.aspx

Convert My SQL database to MS SQL database

I wanted to know if there is a way to convert a .sql file (My SQL backup) to .bak file (MS SQL backup)?
I am currently using MS SQL Server Management Studio Express 2005
Not really. An almost easy way to accomplish this is below.
Install a MySQL server and restore the .sql into it.
Then in your SQL Server create a linked server to the MySQL server.
You can then select the tables in the MySQL server over to SQL Server with something similar to below.
SELECT *
INTO [TABLENAME]
FROM OPENQUERY([LINKEDSERVERNAME], 'SELECT * FROM MYSQLTABLENAME')
Using INFORMATION_SCHEMA on the MySQL server, dynamic SQL, variables and a cursor you can loop through all the tables without coding for each table.
Don't forget to turn off the temporary MySQL instance. It only needs to be on while you're restoring/extracting from it.
And since *.bak are proprietary you have to create that once you've pulled all the tables into the SQL Server DB. Not sure if you really needed the BK or just the SQL Server Database.
While this may sound painful you're really talking less the 50 lines of code. Also, SQL Server will mostly handle the typing for you.