Seven Differences Between Oracle and Microsoft SQL Server (T-SQL) Commands
December 17, 2025 Issue # 37
If you have worked with Microsoft SQL Server (T-SQL) in the past and are now using Oracle, or vice-versa, it is important to know some differences in commands. Structured Query Language (SQL) has variations with various database management systems. In this article, we will focus on the differences between Oracle SQL and Microsoft SQL Server (T-SQL), with examples.
Photos from Unsplash.com
1) Limit rows: FETCH FIRST vs TOP
For Oracle, if you want to return a specific number of rows instead of all records, at the end of your Select Statement, use FETCH. For example: SELECT * FROM employees ORDER BY hire_date DESC FETCH FIRST 10 ROWS ONLY;
For Microsoft SQL, use TOP and the number of records desired after the SELECT command and before FROM. For Example: SELECT TOP (10) * FROM employees ORDER BY hire_date DESC;
2) String concatenation: || vs + / CONCAT
For Oracle, SELECT first_name || ‘ ‘ || last_name AS full_name FROM employees;
For Microsoft SQL, SELECT first_name + ‘ ‘ + last_name AS full_name FROM employees;
3) Date/time: SYSDATE vs GETDATE()
For Oracle, a dummy table, dual, is needed. SELECT SYSDATE FROM dual;
For Microsoft, SELECT GETDATE();
4) Conditional logic: DECODE (Oracle) vs CASE (both)
For Oracle, SELECT DECODE(status, ‘A’,’Active’,’I’,’Inactive’,’Unknown’) AS status_name FROM t;
The case statements below will also work in Oracle with an exception. Oracle requires straight single quotes, ‘ ‘, not curly quotes ‘’.
For Microsoft,
SELECT CASE status
WHEN ‘A’ THEN ‘Active’
WHEN ‘I’ THEN ‘Inactive’
ELSE ‘Unknown’
END AS status_name
FROM t;
5) MINUS (Oracle) vs EXCEPT (SQL Server)
Returns rows that are in the first query, but not in the second.
For Oracle,
SELECT employee_id FROM employees
MINUS
SELECT employee_id FROM terminated_employees;
For Microsoft,
SELECT employee_id FROM employees
EXCEPT
SELECT employee_id FROM terminated_employees;
6) Temporary Table Creation Differences
Microsoft SQL gives more options. With Microsoft, the user can Select into a temporary table, which is a quick and easy way to create a temporary table. Temporary tables begin with # (for Microsoft SQL).
SELECT emp_id, dept_id, salary INTO #temp_employees FROM employees
WHERE dept_id = 10;
The above statement creates #temp_employees, defines columns automatically, and inserts the selected rows. The table exists for your session. Use the temporary table like any other table: For example, SELECT * FROM #temp_employees;
Oracle does not allow SELECT INTO a temporary table. One way is to create a table, then use INSERT INTO.
CREATE GLOBAL TEMPORARY TABLE temp_employees (emp_id NUMBER, dept_id NUMBER, salary NUMBER)
ON COMMIT PRESERVE ROWS;
INSERT INTO temp_employees
SELECT emp_id, dept_id, salary FROM employees WHERE dept_id = 10;
7) Use a WITH Statement ,also called Common Table Expression (CTE)
You may use a WITH statement with both Oracle and SQL. I use it more often in Oracle. CTE’s are named subqueries, not temporary tables, but can sometimes serve the same purpose. After creating the CTE, you are essentially querying a subquery, not a temporary table. CTE’s can be easier to work with than inline subqueries.
WITH emp_dept AS (
SELECT * FROM employees WHERE dept_id = 10
)
SELECT COUNT(*) FROM emp_dept;


