Tip of the Day : Convert Oracle String Functions to SQL Server String Functions

Welcome to SQL Server Helper !!!

This site is intended for those who are beginning to use SQL Server as part of their day-to-day activities.  You will find in this site a collection of useful functions, triggers, stored procedures and tips and tricks related to SQL Server.

Should you have any comments or questions regarding this site or if you want to ask SQL Server-related questions, e-mail us here.

We hope we are able to help and we are glad to help!!!

SQL Server Tip of the Day - March 18, 2019

Convert Oracle String Functions to SQL Server String Functions

Function

Oracle

SQL Server

Convert Character to ASCII

ASCII(p)

ASCII(p)

Convert ASCII to Character

CHR(p)

CHAR(p)

Concatenate Strings

CONCAT(p1, p2)

p1 || p2

p1 + p2

Return Starting Point of Character in Character String

INSTR(p1, p2)

CHARINDEX(p2, p1)

Convert String to All Lower Case

LOWER(p1)

LOWER(p1)

Convert String to All Upper Case

UPPER(p1)

UPPER(p1)

Pad Left Side of Character String

LPAD(p1, p2, p3)

RIGHT(REPLICATE(p3, p2) + p1, p2)

Remove Leading Blank Spaces

LTRIM(p1)

LTRIM(p1)

Remove Trailing Blank Spaces

RTRIM(p1)

RTRIM(p1)

Return Starting Point of Pattern in Character String

INSTR(p1, p2)

PATINDEX(p2, p1)

Pad Right Side of Character String

RPAD(p1, p2, p3)

LEFT(p1 + REPLICATE(p3, p2), p2)

Phonetic Representation of Character String

SOUNDEX(p1)

SOUNDEX(p1)

Convert Numeric Data to String

TO_CHAR(p1)

CAST(p1 as VARCHAR)

Extract a Portion of a String from the Input String

SUBSTR(p1, p2, p3)

SUBSTRING(p1, p2, p3)

Replace Characters

REPLACE(p1, p2, p3)

REPLACE(p1, p2, p3)

Reverse String

REVERSE(p)

REVERSE(p)

Capitalize First Letter of Each Word in String

INITCAP(p1)

Not Available

Translate Character String

TRANSLATE(p1)

Not Available

Return Length of String

LENGTH(p)

LENGTH(p)

Return Length of String in Bytes

LENGTHB(p)

DATALENGTH(p)

Greatest Character String in List

GREATEST(p1, p2, …)

Not Available

Least Character String in List

LEAST(p1, p2, …)

Not Available

Replace String if NULL

NVL(p1, p2)

ISNULL(p1, p2)

Return NULL if both Expressions are the Same.

NULLIF(p1, p2)

NULLIF(p1, p2)

SQL Server 2012

SQL Server 2008

User-Defined Functions

Date Functions

A collection of useful user-defined functions that deal with dates.

String Functions

A collection of useful user-defined functions that deal with strings (varchar/char/nvarchar/nchar).

Tree Functions

A collection of useful user-defined functions that deal with tree or hierarchical design structures.

Table-Valued Functions

A collection of useful table-valued user-defined functions that can be used to join with other tables.

SQL Server Built-in Functions

A reference to all built-in functions available within SQL Server grouped into categories.

Tips and Tricks

A collection of useful SQL Server-related tips and tricks:

SQL Server Error Messages

A list of SQL Server error messages and for certain error messages, discusses ways on how to solve the error or work around them:

Frequently Asked Questions