Turning MySQL queries into SQL Server queries - mysql

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.

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.

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.

Is it possible to Connecting MYsql with sql server?

I am using an open source software which support mysql and i create application that uses asp.net 4.0 and sql server 2008....
Is it possible to Connecting MYsql with sql server ?
I want every insertion and updating should be made to both database servers as they have same schema of tables but one is mysql and other is sql server 2008 ?
kindly explain step by step if possible
hope this will help,this shows step by step connection
http://www.codeproject.com/Articles/29106/Migrate-MySQL-to-Microsoft-SQL-Server
You can use linked server in MS SQL Server.
From the documentation - A linked server allows for access to distributed, heterogeneous queries against OLE DB data sources.
Have a look at sp_addlinkedserver function.

MySql syntax in SQL Server to set display length of datatype

We got some SQL scripts, some of them are using Syntax like :
Create procedure procABC(...)
as
begin
...
...
'ColA'= CONVERT(smalldatetime(10),ColB,103),
...
...
End
Same kind of syntax we also have for INTEGER like
INTEGER(5)
I know that this kind of syntax is used in MySql to set display width of a column or variable. But In any of the SQL Server version starting from SQL 7 to SQL 2008 this syntax fails.So my question is :
We have got this script from a SQL server machine as a backup, is it possible to have some kind of cached scripts, like we have in ORACLE where script may be invalid but still it will be on the server in invalid mode and will give compilation error if there are any syntax errors..
Is there anyway to achieve same kind of functionality in SQL server as we are supposed to re-create these objects (Something other then SUBSTRING) .
If I understand your additional information correctly, you have a SQL Server 2000 database that was created by some scripts, but the only scripts you have are in MySQL syntax and you're not sure how they are related to the SQL Server database. Your goal is to create a set of scripts that can be used to re-create the SQL Server 2000 database on a SQL Server 2008 system.
First, if that understanding is correct then I would completely forget about the MySQL scripts. They might have some value as documentation if there are useful comments in them, but they are not directly necessary for your task.
Second, I would upgrade your SQL 2000 database to SQL 2008. You can back it up and restore it on a SQL 2008 server, or you can upgrade the entire SQL Server itself from 2000 to 2008.
Third, I would generate the SQL scripts for the database objects using SQL Server Management Studio or the SMO API if you prefer. A Visual Studio database project could also be a good way to manage the scripts.
There is plenty of information on all these tasks on this site, in the SQL Server documentation, on MSDN etc. If you need more help, you should ask more precise questions about what you want to do and what you have tried already.

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