Home > Documentation > MySQL to MS SQL
One of the important steps of MySQL to SQL Server database migration is queries conversion. This article gives 20 tips on how to modify MySQL views to make it compatible with Microsoft SQL Server format. The target audience for this guide should have general database management knowledge and experience in composing SQL queries.
First, you need to get list of all views in database as follows:
SELECT table_name, view_definition FROM information_schema.views WHERE table_schema='0atabase name%';
And then start to modify each MS SQL view query according to the following rules:
ORDER BY...
clause, it is necessary to insert
TOP 100 PERCENT
right after SELECT
keywordnow()
by getdate()
JOIN ... WHERE
by CROSS JOIN ... WHERE
isnull(expression)
by expression is null
from_unixtime(expression)
by
DateAdd(ss, expression, '01-01-1970')
curdate()
by getdate()
Also you should remember that unlike MySQL SQL Server requires all selected columns in
SELECT ... GROUP BY ...
queries to be either under GROUP BY
clause
or in aggregation functions.
Of course, there are a lot of newances staying outside of this article, it just covers the most frequent issues in migrating views from MySQL to MS SQL. If you need a solution for complete migration of MySQL database to MS SQL server, take a look at MySQL-to-MSSQL converter.
Have any questions? Contact us