How to convert MYSQL query into MSSQL query

11,411

From this article by Brian Swan, you can download the SQL Server Migration Assistant for MySQL tool and use it to convert a single MySQL query to a SQL Server query:

  1. Create a Project: All the information you need for downloading SSMA, creating a project and connecting to databases is in steps 1-6 of this blog post.

  2. In the MySQL Metadata Explorer, navigate to the Statements directory of your MySQL database:

enter image description here

  1. Paste the query you want to convert into the query editor window, e.g: SELECT post_title, post_date FROM wp_posts ORDER BY post_date LIMIT 5 OFFSET 5;

enter image description here

  1. Back in the MySQL metadata explorer, right-click Statements and select Convert Schema:

enter image description here

  1. When prompted to save changes, select Yes:

enter image description here

  1. Copy the converted query from the SQL Server query editor window:

enter image description here

Note that SSMA will not successfully translate all MySQL queries, but it does for most. It does not translate some MySQL-specific functions (for example FOUND_ROW()).

Share:
11,411
user3114967
Author by

user3114967

Updated on June 04, 2022

Comments

  • user3114967
    user3114967 almost 2 years

    I've 700+ MySQL queries and now trying to create same set of queries in MSSQL.

    I want to generate MSSQL query with same MYSQL.Is any way to convert MYSQL query into MSSQL query.

  • user3114967
    user3114967 over 9 years
    I'm using SQL Yog and there is no Statement option in that. Can you tell me how to do that with SQL Yog.
  • user3114967
    user3114967 over 9 years
    Yes I installed SSMA. I created statement and paste one create query in Sql Editor but convert schema option disabled when I right-clicked created statement. How can I enable convert schema??
  • chridam
    chridam over 9 years
    Did you actually follow the step-by-step installation instructions from this blog post?
  • user3114967
    user3114967 over 9 years
    yes, I can create statement,save,create Report but convert schema option disabled.