SQL Server Functions and Oracle Equivalent (2024)

Introduction

This article looks at SQL Server string, numeric, and date functions and their Oracle equivalents. I used TOAD as an application tool for Oracle to query the database.

String Functions

SQL Server has a variety of string functions that are very useful for manipulating the string data type. SQL Server uses various data types to store the string and character types of data (in other words, varchar, nvarchar, and char). So we can use the string functions to get the desired and specific results. Find more about Functions in SQL Server here: Functions in SQL Server.

LEN(string)-The Length function in SQL Server gets the length of the string specified in the expression.

SQL Server Functions and Oracle Equivalent (1)

Note.In SQL Server, the LEN function does not consider trailing blanks.

SQL Server Functions and Oracle Equivalent (2)

Oracle's Equivalent

The Oracle's equivalent is LENGTH. Dual is a special table in Oracle.

SELECT LENGTH ('Telnet') FROM DUAL;

SQL Server Functions and Oracle Equivalent (3)

In Oracle, the Trailing Spaces are taken into account for determining the length of the string like this:

SQL Server Functions and Oracle Equivalent (4)

LOWER (expr)

The LOWER function is self-explanatory; it converts upper-case data to lowercase for the given expression.

SQL Server Functions and Oracle Equivalent (5)

Oracle's Equivalent

SQL Server Functions and Oracle Equivalent (6)

UPPER(expr)

The UPPER Function converts the lowercase expression to uppercase.

SQL Server Functions and Oracle Equivalent (7)

Oracle's Equivalent

The equivalent upper function in Oracle is UPPER.

SQL Server Functions and Oracle Equivalent (8)

LTRIM(string)

The LTRIM function in SQL Server removes leading spaces.

SQL Server Functions and Oracle Equivalent (9)

Oracles Equivalent

SQL Server Functions and Oracle Equivalent (10)

RTRIM(string)

The RTRIM function removes trailing spaces in SQL Server.

SQL Server Functions and Oracle Equivalent (11)

Oracle's Equivalent

SQL Server Functions and Oracle Equivalent (12)

We use the TRIM function in Oracle to remove leading and trailing spaces. In SQL Server, we use the combination of LTRIM and the TRIM function to remove the leading and trailing spaces.

SQL Server Functions and Oracle Equivalent (13)

LEFT (string, length)

The left function in SQL Server returns a specified number of characters from the beginning of the string.

SELECT LEFT('Keyboard',3)

SQL Server Functions and Oracle Equivalent (14)

Oracle's Equivalent

In Oracle, the SUBSTRING function gets a part ofa string.

SQL Server Functions and Oracle Equivalent (15)

RIGHT (string, length)

The right function in SQL Server returns the specified number of characters from the end of the string.

SQL Server Functions and Oracle Equivalent (16)

Oracle's Equivalent

There is no direct function to do this in Oracle; we can use the SUBSTR function again.

SQL Server Functions and Oracle Equivalent (17)

We use the function above to get the last five characters at the end of the string.

LPAD Function

In SQL Server, we use the RIGHT and REPLICATE functions to do the LPAD function.

SQL Server Functions and Oracle Equivalent (18)

Oracle's Equivalent

In Oracle, we have the LPAD function to pad the string with the specified characters.

SQL Server Functions and Oracle Equivalent (19)

RPAD Function

To RPAD characters to a string, we use the combination of the LEFT and REPLICATE functions.

SQL Server Functions and Oracle Equivalent (20)

Oracle's Equivalent

In Oracle, we have the RPAD function to pad the string with the specified characters on the right side.

SQL Server Functions and Oracle Equivalent (21)

SUBSTRING(string,start_position,length)

The Substring function in SQL Server extracts a part of the string from the given string.

SQL Server Functions and Oracle Equivalent (22)

This gets the first two characters of the String "Lenovo." Here the start position is one, so it starts with the first letter and returns the first two characters since the length specified is two.

Oracle's Equivalent

In Oracle, we have the SUBSTR function to return the specified part of the substring.

SQL Server Functions and Oracle Equivalent (23)

REPLACE (input_string ,string_to_replace, replacement_string)

The replace function replaces a sequence of characters in a string with another set of characters.

SQL Server Functions and Oracle Equivalent (24)

Oracle Equivalent

Oracle has its REPLACE function with the same syntax as SQL Server.

SQL Server Functions and Oracle Equivalent (25)

REVERSE(string)

The reverse function returns the given input string in reverse order.

SQL Server Functions and Oracle Equivalent (26)

Oracle's Equivalent

In Oracle, we use the REVERSE function.

SQL Server Functions and Oracle Equivalent (27)

Numeric Functions

ISNUMERIC(expression)

The ISNUMERIC function in SQL Server returns a value of 1, indicating that the given expression isa numeric value. It returns a value of 0 otherwise.

Numeric Expression

SQL Server Functions and Oracle Equivalent (28)

Non-Numeric Expression

SQL Server Functions and Oracle Equivalent (29)

Oracle's Equivalent

In Oracle, we use a combination of LEN, TRIM, and TRANSLATE functions to check a string for a numeric value.

SELECT LENGTH (TRIM (TRANSLATE ('1256.54', ' +-.0123456789',' ')))FROM DUAL;

(Or)

We can create a Custom function in Oracle to check for numeric values.

CREATE OR REPLACE FUNCTION ISNUMERIC (PARAM IN CHAR) RETURN NUMBER AS DUMMY VARCHAR2 (100);BEGIN DUMMY := TO_CHAR(TO_NUMBER(PARAM)); RETURN (1);EXCEPTION WHEN VALUE_ERROR THEN RETURN (0);END;/

ABS(number)

Returns the absolute value of a number.

SQL Server Functions and Oracle Equivalent (30)

Oracle's Equivalent

In Oracle, we have the ABS function as in SQL Server.

SQL Server Functions and Oracle Equivalent (31)

CEILING (number)

The ceiling function returns an integer value greater than or equal to the given number.

SQL Server Functions and Oracle Equivalent (32)

Oracle's Equivalent

The CEILING function's equivalent in Oracle is CEIL.

SQL Server Functions and Oracle Equivalent (33)

FLOOR(number)

The Floor function returns an integer value that is less than or equal to the number specified.

SQL Server Functions and Oracle Equivalent (34)

Oracle's Equivalent

SQL Server's equivalent of the FLOOR function in Oracle is FLOOR.

SQL Server Functions and Oracle Equivalent (35)

Date-Time Functions

GETDATE()

The GETDATE () function returns the current System Date and Time.

SQL Server Functions and Oracle Equivalent (36)

Oracle's Equivalent

To get the current date and time in Oracle, we use the SYSDATE function.

SQL Server Functions and Oracle Equivalent (37)

DAY(date)

The DAY function returns the day for the given date as an integer value.

SQL Server Functions and Oracle Equivalent (38)

Oracle's Equivalent

In Oracle, we can use the TO_CHAR function or the EXTRACT function to do this.

SQL Server Functions and Oracle Equivalent (39)

(Or)

SQL Server Functions and Oracle Equivalent (40)

MONTH(date)

The Month function returns the month for the specified date as an integer value.

SQL Server Functions and Oracle Equivalent (41)

Oracle's Equivalent

SQL Server Functions and Oracle Equivalent (42)

(Or)

SQL Server Functions and Oracle Equivalent (43)

YEAR(date)

The YEAR function returns the year part for the given date.

SQL Server Functions and Oracle Equivalent (44)

Oracle's Equivalent

SQL Server Functions and Oracle Equivalent (45)

(Or)

SQL Server Functions and Oracle Equivalent (46)

Date-Time Conversion Functions

Date to String

To convert a DATE to VARCHAR in SQL Server, we use the CONVERT function in SQL Server.

SQL Server Functions and Oracle Equivalent (47)

Here the output string is in the format mm/dd/yyyy, which is the USA Standard format for specifying the date.

101 - The Styleto convert the date to USA Standard format is in the query.

In Oracle, we use the TO_CHAR function to get the specified format.

SQL Server Functions and Oracle Equivalent (48)

String to Date

In SQL Server, we use the CONVERT function to convert between the date to string as well string to date.

SQL Server Functions and Oracle Equivalent (49)

Without the Style specified, the query will not return the correct date.

Oracle's Equivalent

To convert a string to date in Oracle, we use the TO_DATE function.

SQL Server Functions and Oracle Equivalent (50)

Conclusion

This article taught us some SQL Server functions and Oracle's Equivalent SQL. I hope this article might help to learn a little.

SQL Server Functions and Oracle Equivalent (2024)

FAQs

What is the difference between Oracle and SQL Server functions? ›

Oracle has unique features like parallel query processing, timely customer support services, and 24×7 error handling capabilities. SQL Server is a good option if speed and processing power are not your main concern.

What is the equivalent of Oracle in SQL Server? ›

SQL Server has a TEXT datatype and the Oracle equivalent to this is the LONG datatype.

What is the SQL Server equivalent of Oracle Instr function? ›

The CHARINDEX function is used in Microsoft SQL Server to retrieve the position of a substring in the specified string. Oracle uses with this purpose the INSTR function. These functions have a similar syntax and differ in the parameter order.

How is Microsoft SQL Server compared to Oracle? ›

Although both Oracle and SQL Server are built on SQL, they do have a number of differences. Microsoft SQL Server uses Transact-SQL, while Oracle uses PL/SQL. These two variations have different syntax, capabilities, and handle some things (like variables, built-in functions, and stored procedures) differently.

Why use Oracle instead of SQL? ›

Oracle uses SQL language along with other RDBMS databases provide the SQL too like SQL Server by Microsoft, Mysql by Oracle, Postgresql etc.. Oracle SQL is way more powerful than any RDBMS provider and it has a lot of extra features. It has also a great market capture rate in terms of RDBMS database.

When to use Oracle functions? ›

We use stored procedures or functions in Oracle for performing specific tasks. Tasks can be for example to get some value from database or to do some processings like to validate any address based on some rules.

What is Oracle synonym in SQL Server? ›

Oracle uses a public synonym only when resolving references to an object if the object is not prefaced by a schema and the object is not followed by a database link. If you omit this clause, the synonym is private and is accessible only within its schema. A private synonym name must be unique in its schema.

How to compare data between SQL Server and Oracle? ›

One gotcha to watch out for in the comparison is thatin SQL Server a varchar or nvarchar of '' is a non-null empty string. In Oracle '' the same as null. Depending on your comparison tools and methods SQL Servers '' may be flagged as different from Oracle's '' because of that.

Which database is closest to Oracle? ›

Top Oracle Alternatives
  • Microsoft.
  • IBM.
  • Amazon Web Services (AWS)
  • MongoDB.
  • Google.
  • SAP.
  • MariaDB.
  • Cloudera.

How to convert Oracle function to SQL Server? ›

Recommended migration process
  1. Create a new SSMA project. ...
  2. Connect to the Oracle database server.
  3. Connect to an instance of SQL Server.
  4. Map Oracle database schemas to SQL Server database schemas.
  5. Optionally, Create assessment reports to assess database objects for conversion and estimate the conversion time.
Aug 1, 2023

What is the schema equivalent of SQL Server in Oracle? ›

The Oracle concept of a schema maps to the SQL Server concept of a database and one of its schemas. For example, Oracle might have a schema named HR. An instance of SQL Server might have a database named SampleDatabase, and within that database are multiple schemas.

What is the SQL Server equivalent of Oracle NVL? ›

ISNULL replaced the Oracle NVL function in the SQL server.

Which is faster SQL Server or Oracle? ›

When it comes to performance, both SQL Server and Oracle are very powerful. However, Oracle is known to perform better in larger-scale enterprise-level applications. SQL Server is a good option for smaller-scale applications.

What is the difference between MySQL and Oracle? ›

Oracle is optimized for large-scale operations with high-performance strategies and Real Application Clusters, whereas MySQL excels at managing smaller-scale relational databases and offers both vertical and horizontal scalability.

What is the difference between Oracle and SQL Server stored procedures? ›

The main difference between the two languages is how they handle variables, stored procedures, and built-in functions. PL/SQL in Oracle can group procedures into packages, which cannot be done in MS SQL Server." While PL/SQL is more complex and has more' capabilities,' T-SQL is simpler and easier to use.

What is the difference between Oracle schema and SQL Server schema? ›

Oracle and SQL Server Schemas

An Oracle database contains schemas. An instance of SQL Server contains multiple databases, each of which can have multiple schemas. The Oracle concept of a schema maps to the SQL Server concept of a database and one of its schemas. For example, Oracle might have a schema named HR.

Does SQL Server have functions? ›

SQL Server has many built-in functions. This reference contains string, numeric, date, conversion, and some advanced functions in SQL Server.

Top Articles
What SSL Certificate Port Does SSL Use? Explained by SSL Experts
Unlocking Your Ultimate Hair Potential: From the Inside Out
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 5894

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.