Oracle SQL Server

Oracle to SQL Server Converter: Syntax Guide & Examples

A complete reference for converting Oracle SQL and PL/SQL to SQL Server T-SQL. Covers NVL to ISNULL, SYSDATE to GETDATE(), ROWNUM to TOP, and procedural code migration.

Mar 11, 2026 10 min read

Why Convert Oracle to SQL Server?

Many enterprises migrate from Oracle to SQL Server to consolidate on the Microsoft stack. If your organization already uses Windows Server, Active Directory, .NET, and Azure, SQL Server integrates seamlessly. Microsoft's licensing model, while not free, is typically more predictable and less expensive than Oracle's per-core licensing.

SQL Server also offers strong BI integration with Power BI, SSRS (SQL Server Reporting Services), and SSIS (SQL Server Integration Services). For organizations that need analytics and ETL alongside their transactional database, this integrated ecosystem is a significant advantage.

The migration involves converting Oracle-specific SQL syntax, PL/SQL procedures to T-SQL, and Oracle data types to SQL Server equivalents. Microsoft provides free migration tools (SSMA) that automate much of this work.

Key Syntax Differences

Feature Oracle SQL Server
NULL replacementNVL(a, b)ISNULL(a, b)
Current datetimeSYSDATEGETDATE() / SYSDATETIME()
Row limitingWHERE ROWNUM <= 10SELECT TOP 10
String concatenationa || ba + b or CONCAT(a, b)
Sequence next valueseq.NEXTVALNEXT VALUE FOR seq
Dual tableSELECT 1 FROM DUALSELECT 1
DECODEDECODE(col, v1, r1)IIF or CASE WHEN
Date arithmeticSYSDATE + 30DATEADD(DAY, 30, GETDATE())
Outer join(+) operatorStandard LEFT/RIGHT JOIN
Procedural languagePL/SQLT-SQL

Common Conversions with Examples

NVL to ISNULL

-- Oracle
SELECT NVL(nickname, name) AS display_name FROM users;
SELECT NVL2(commission, salary + commission, salary) FROM employees;
-- SQL Server
SELECT ISNULL(nickname, name) AS display_name FROM users;
SELECT IIF(commission IS NOT NULL, salary + commission, salary) FROM employees;

ROWNUM to TOP

-- Oracle
SELECT * FROM employees WHERE ROWNUM <= 10;

SELECT * FROM (
    SELECT e.*, ROWNUM rn FROM employees e ORDER BY salary DESC
) WHERE rn BETWEEN 11 AND 20;
-- SQL Server
SELECT TOP 10 * FROM employees;

SELECT * FROM employees
ORDER BY salary DESC
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;

SYSDATE to GETDATE()

-- Oracle
SELECT SYSDATE FROM DUAL;
SELECT * FROM orders WHERE order_date > SYSDATE - 30;
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
-- SQL Server
SELECT GETDATE();
SELECT * FROM orders WHERE order_date > DATEADD(DAY, -30, GETDATE());
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd HH:mm:ss');

DECODE to CASE / IIF

-- Oracle
SELECT DECODE(status, 'A', 'Active', 'I', 'Inactive', 'Unknown') FROM users;
-- SQL Server
SELECT CASE status
    WHEN 'A' THEN 'Active'
    WHEN 'I' THEN 'Inactive'
    ELSE 'Unknown'
END FROM users;

Sequences

-- Oracle
CREATE SEQUENCE order_seq START WITH 1 INCREMENT BY 1;
INSERT INTO orders (id, customer) VALUES (order_seq.NEXTVAL, 'Alice');
-- SQL Server (2012+)
CREATE SEQUENCE order_seq START WITH 1 INCREMENT BY 1;
INSERT INTO orders (id, customer) VALUES (NEXT VALUE FOR order_seq, 'Alice');

-- Or use IDENTITY instead of sequences
CREATE TABLE orders (
    id INT IDENTITY(1,1) PRIMARY KEY,
    customer NVARCHAR(100)
);

String Concatenation

-- Oracle
SELECT first_name || ' ' || last_name FROM employees;
-- SQL Server
SELECT first_name + ' ' + last_name FROM employees;
-- Or using CONCAT (NULL-safe):
SELECT CONCAT(first_name, ' ', last_name) FROM employees;

Data Type Mapping

Oracle Type SQL Server Type Notes
NUMBER(10)INT or BIGINTBased on precision
NUMBER(10,2)DECIMAL(10,2)Same precision
VARCHAR2(n)NVARCHAR(n)Unicode support
CHAR(n)NCHAR(n)Fixed-length Unicode
CLOBNVARCHAR(MAX)Up to 2GB
BLOBVARBINARY(MAX)Binary data
DATEDATETIME2Oracle DATE includes time
TIMESTAMPDATETIME2(7)Nanosecond precision
BINARY_FLOATREAL4-byte float
BINARY_DOUBLEFLOAT8-byte float
RAW(n)VARBINARY(n)Binary
XMLTYPEXMLBoth have native XML

Step-by-Step Migration Guide

  1. Use SSMA for Oracle. Microsoft's free SQL Server Migration Assistant for Oracle automates schema conversion, data type mapping, PL/SQL to T-SQL translation, and data migration. Download it from the Microsoft website.
  2. Convert the schema. Replace VARCHAR2 with NVARCHAR, NUMBER with INT/DECIMAL, CLOB with NVARCHAR(MAX), and Oracle DATE with DATETIME2.
  3. Convert SQL queries. Replace NVL with ISNULL, SYSDATE with GETDATE(), ROWNUM with TOP, || with +, DECODE with CASE, and remove FROM DUAL.
  4. Convert PL/SQL to T-SQL. Key changes: replace DBMS_OUTPUT.PUT_LINE with PRINT, Oracle cursors with T-SQL cursor syntax, EXCEPTION WHEN with TRY...CATCH, and Oracle packages with T-SQL stored procedures grouped in schemas.
  5. Handle empty string behavior. Oracle treats empty string as NULL. SQL Server treats them as distinct. Review code that relies on this Oracle behavior and add explicit NULL checks.
  6. Test and validate. Run both systems in parallel and compare query results. Use SSMA's built-in comparison reports to identify discrepancies.

For SQL fundamentals, see What is SQL. For join syntax, see SQL Joins Explained.

Convert Automatically with AI2SQL

Paste your Oracle query into the SQL Converter tool and get correct T-SQL with ISNULL, GETDATE(), TOP, and proper data types automatically.

Try the converter free. See also: Oracle to PostgreSQL. Browse all converter tools.

Frequently Asked Questions

What is the SQL Server equivalent of Oracle NVL?

SQL Server uses ISNULL(a, b) as the equivalent of Oracle's NVL(a, b). Both return the second argument if the first is NULL. SQL Server also supports COALESCE which accepts multiple arguments and is SQL standard, working in both databases.

How do I convert Oracle ROWNUM to SQL Server?

Use TOP or OFFSET-FETCH. Oracle: SELECT * FROM employees WHERE ROWNUM <= 10. SQL Server: SELECT TOP 10 * FROM employees. For pagination, SQL Server 2012+ supports OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY. Both databases support ROW_NUMBER() OVER (ORDER BY col) for complex numbering.

Can I use SQL Server Migration Assistant for Oracle migration?

Yes. Microsoft provides SQL Server Migration Assistant (SSMA) for Oracle, a free tool that automates schema conversion, data type mapping, and data migration. It handles most PL/SQL to T-SQL conversion automatically and generates assessment reports showing potential issues.

Convert Oracle to SQL Server Instantly

Paste your Oracle query and get correct T-SQL syntax generated automatically with our free converter tool.

Convert Now - Free

No credit card required