Ask Your Question
3

How can a query be translated from MySQL to SQL Server?

asked 2021-09-11 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-10-06 14:00:00 +0000

devzero gravatar image

There are a few key syntax differences between MySQL and SQL Server, so the translation of a query from MySQL to SQL Server requires some adjustments. Here are some tips to translate a simple SELECT statement:

  1. Change the backticks (`) used in MySQL to double quotes (") used in SQL Server to enclose object names such as table or column names.

  2. Replace the limit clause at the end of the MySQL statement with the syntax "TOP n" in the SELECT statement in SQL Server.

  3. Replace the "DATE_FORMAT" function in MySQL with the "CONVERT" function in SQL Server.

  4. Replace the "IFNULL" function in MySQL with the "ISNULL" function in SQL Server.

  5. Replace the "GROUPCONCAT" function in MySQL with the "STRINGAGG" function in SQL Server.

  6. Replace the "SUBSTR" function in MySQL with the "SUBSTRING" function in SQL Server.

  7. Replace the "NOW()" function in MySQL with the "GETDATE()" function in SQL Server.

Overall, the syntax and function names in MySQL and SQL Server are slightly different, so it is important to consult the SQL Server documentation and refer to syntax guides to make any necessary adjustments.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-09-11 11:00:00 +0000

Seen: 11 times

Last updated: Oct 06 '22