Migration of an Oracle database to Microsoft SQL server involves converting Oracle queries into the destination format. The syntax of queries in Oracle and SQL is similar, yet not equal. Also, these two DBMS have distinguished sets of built-in functions. Learn more about the most important differences between Oracle and MS SQL syntax.
- Oracle’s operator (+) is specific notation for LEFT OUTER JOIN. In Microsoft SQL it must be replaced by LEFT JOIN.
- Oracle’s function TO_DATE must be replaced by CONVERT in Microsoft SQL.
- Oracle’s CONCAT($s1, $s2) function returns $s2 appended or concatenated to $s1. MS SQL does not have the equivalent function, so it must be replaced by concatenation operator, the plus sign.
- Oracle’s function nvl($var, $expr) that returns $expr if $var is NULL must be replaced by MS SQL equivalent ISNULL($var, $expr).
- Oracle’s function nvl2($var,$expr1,$expr2) that returns $arg2 if $var is NULL and $arg1 if $var is not NULL must be replaced in MS SQL as follows:
CASE WHEN $var IS NOT NULL THEN $arg1 ELSE $arg2 END
- Oracle’s function SYSDATE that returns the current date and time must be replaced by GETDATE().
- Oracle does not require aliases for subqueries, while Microsoft SQL require it.
- Oracle’s function TO_DATE must be replaced by CONVERT as follows:
TO_DATE( $date, 'YYYYMMDD' ) - CONVERT( DATETIME, $date )
- Oracle’s function ADD_MONTHS($datetime, $n) that adds $n months to $datetime must be replaced by DATEADD($month, $n, datetime) in MS SQL.