Convert Oracle Queries into Microsoft SQL Format

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.
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of