SQL Server Query to MySQL query conversion
I am doing query conversion from SQL Server to MySQL. So can anyone suggest a website which provides the different keywords that will do the same operation in SQL Server and MySQL respectively?
For example, To get the current time we will use following keywords
MSSQL getdate()
MYSQL now()
开发者_开发百科like this, for all the operations I need keywords.
I did it a few times, my suggestion is to google as following
Mssql getdate() in Mysql
and than you get to sites like http://www.x7media.com/resources/SQL_Differences_Between_Microsoft_SQL_Server_and_MySQL.asp
Have you looked at the MySQL documentation available on the web site?
A quick search found this: A Practical Guide to Migrating From Microsoft SQL Server to MySQL
You have to register to get the document but it's probably worth a read.
I also found this page: Migrating from Microsoft SQL Server and Access to MySQL
Which has some general information on the process and list some migration tools (although some may be specific to Access)
Since the syntax of SQL queries in MS SQLand MySQL are similar but not identical, here are a few tips on converting MS SQL to queries to MySQL:
MySQL does not allow square brackets around table of column names, they all must be replaced by
`symbol or cut off. For instance: [object] will be `object`.When it comes to
JOINconstructions, the keywordWHEREinMS SQLis replaced byONinMySQL. For example:... table1 CROSS JOIN table2 WHERE conditionmust be translated into... table1 CROSS JOIN table2 ON condition.When using PHP, most of the SQL functions in
MS SQLhave the prefix SQLSRV, whereas the functions inMySQLhave the prefix MYSQL. For example:sqlsrv_fetch_array,sqlsrv_num_rows,sqlsrv_querywill be converted tomysql_fetch_array,mysql_num_rows,mysql_query.In MS SQL, the
LEN()function is used to return the length of string expression. TheMySQLequivalent of this isLENGTH().CONVERT() function is used to convert an expression of one data type to another in MS SQL. In MySQL, the CONVERT() function converts text data between different character sets. However, there is equivalent function CAST(), so every occurrence of convert(type, expression) in MS SQL query must be replaced by cast(expression AS type) in MySQL query.
Just to list but a few hints. Refer to this page for more. Cheers!
加载中,请稍侯......
精彩评论