Convert My SQL database to MS SQL database - mysql

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.

Related

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.

Migrate mysql tables to existing sql database

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/

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

Turning MySQL queries into SQL Server queries

I was given the task of building a database and the queries to interact with it.
They did not tell me what kind of database to use, so I chose the one I know: MySQL
Now It seems that the database has to be a SQL Server one and dead line for this task is within hours :(
I have already converted the database from MySQL to SQL Serverusing a program called DBConvert.
But now I have to change all my queries and I have no idea about SQL Server.
Is there any program/web that can do the magic, that can turn MySQL queties into SQL Serverones?
I'm learning about the SQL Serverenvironment so I'm installing the NET Framework and SQL Server 2005 Express, is that correct?
I'm looking for something like phpMyAdmin in SQL Server, is it SQL Server 2005 Express?
Sorry for all of this questioning, but as I said it is a matter of hours.
First of all the SQL Server 2005 Express is the MYSQL server and not like phpMyAdmin. For phpmyAdmin of SQL Server you can use MSSQL query analyzer (if you install MSSQL whole package this will be installed)
And I dont think so there is any program which will convert MYSQL queries to MSSQL queries.

SQL Server Backup to MySQL

I want to back up SQL Server Database and than LATER import it into MySQL. Is there any tool for it?
I would rather have portable SQL file(without SQL Server specific SQL)
For small and medium databases. I've used script from this page.
http://kofler.info/english/mssql2mysql/
http://kofler.info/uploads/mysql/mssql2mysql.txt