RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL
Expertise: Intermediate
Dec 2, 2016



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Convert Oracle Queries into Microsoft SQL Format

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.

  1. Oracle's operator (+) is specific notation for LEFT OUTER JOIN. In Microsoft SQL it must be replaced by LEFT JOIN.
  2. Oracle's function TO_DATE must be replaced by CONVERT in Microsoft SQL.
  3. 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.
  4. Oracle's function nvl($var, $expr) that returns $expr if $var is NULL must be replaced by MS SQL equivalent ISNULL($var, $expr).
  5. 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
  6. Oracle's function SYSDATE that returns the current date and time must be replaced by GETDATE().
  7. Oracle does not require aliases for subqueries, while Microsoft SQL require it.
  8. Oracle's function TO_DATE must be replaced by CONVERT as follows:
    TO_DATE( $date, 'YYYYMMDD' ) - CONVERT( DATETIME, $date ) 
  9. Oracle's function ADD_MONTHS($datetime, $n) that adds $n months to $datetime must be replaced by DATEADD($month, $n, datetime) in MS SQL.
Andrew Kuprianov
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date