Anyone converting code from MS SQL Server to MySQL needs to find equivalent or similar functions. Below is a list of MS SQL Server functions with their MySQL equivalents — some functions have no direct match, but the same result can be achieved with different SQL.
| MS SQL Server | MySQL | Description | MSSQL to MySQL |
|---|---|---|---|
| ASCII | ASCII() | Returns ASCII value of a char | Same functionality in both. See example |
| CHAR | CHAR() | Returns the character of an ASCII value (reverse of ASCII) | Similar with some differences. Example |
| CHARINDEX | LOCATE(), INSTR() | Checks whether a string occurs within another string | Same functionality. Examples |
| CONCAT or + operator | CONCAT() / CONCAT_WS | Joins two or more strings together | CONCAT was introduced in SQL Server 2012; earlier versions use +. MySQL uses CONCAT or CONCAT_WS (+ is not allowed). Examples |
| DIFFERENCE | — | Difference between the SOUNDEX values of two strings | No MySQL equivalent. Microsoft docs |
| FORMAT | FORMAT, DATE_FORMAT | Formats numbers and date/time values | MySQL FORMAT handles numbers; DATE_FORMAT handles date/time. More info |
| LEFT | LEFT | Returns characters from the left of a string | Same functionality. Details with examples |
| LEN | LENGTH, CHAR_LENGTH | Returns the length of a string | Similar with a difference. Details |
| LOWER | LCASE, LOWER | Converts a string to lower case | Same functionality. More |
| LTRIM | LTRIM | Removes leading blank spaces | Same functionality. Examples |
| NCHAR | — | — | — |
| PATINDEX | — | Like CHARINDEX but supports wildcards | No similar MySQL function. Example |
| QUOTENAME | — | Returns a unicode string with delimiters added | No similar function — create one manually. See example |
| REPLACE | REPLACE | Replaces all occurrences of a value with another | Same function, but MSSQL is case-insensitive while MySQL is case-sensitive. Examples |
| REPLICATE | REPEAT | Repeats a string a specified number of times | Achieved with REPEAT in MySQL. Examples |
| REVERSE | REVERSE | Returns a string in reverse order | Same functionality. Examples |
| RIGHT | RIGHT | Returns characters from the right of a string | Same functionality. Examples |
| RTRIM | RTRIM | Removes trailing blank spaces | Same functionality. Examples |
| SOUNDEX | SOUNDEX | Checks the pronunciation of a word | Same function, same name. Examples |
| SPACE | SPACE | Returns a string of spaces | Same function, same name. More details |
| STR | CAST(N as CHAR) | Converts a number to a string | No exact match — CAST mimics it. Comparison & examples |
| STRING_ESCAPE | — | Escapes special characters (SQL Server 2016+) | — |
| STRING_SPLIT | — | Splits a string using a separator (SQL Server 2016+) | No similar function — write one manually, as shown here |
| STUFF | INSERT | Embeds a string within another, replacing characters | Achieved with INSERT in MySQL. Details |
| SUBSTRING | SUBSTR, SUBSTRING, SUBSTRING_INDEX | Returns part of a string | MySQL SUBSTRING has more features than MSSQL's. More |
| UNICODE | — | Returns the Unicode value of the first character | — |
| UPPER | UCASE, UPPER | Converts a string to upper case | Same functionality. Examples |
You can download the MSSQL to MySQL Converter — it converts MSSQL functions to their MySQL equivalent automatically while converting views.