Overview
The REVERSE function is used to provide the string characters in the reverse order.
Explanation
Syntax
REVERSE(expression)Parameters
- expression – this is a string, number, binary data or expression to be reversed.
Simple REVERSE Example
Below is a simple example of using REVERSE function to reverse the word ROME.
SELECT REVERSE('ROME') as msg 
REVERSE Example Using a Table
The following example will reverse the FirstName from the Person table.
SELECT FirstName, REVERSE(FirstName) as reversename
FROM [Person].[Person]
REVERSE Example with Numbers
The following example will reverse the numbers.
SELECT REVERSE(12345) as msg 
REVERSE with NULL values
If the parameter is NULL the value returned by the function will be null as well.
SELECT REVERSE(null) as msg 
REVERSE Function with RIGHT and CHARINDEX
In this example, we want to get the text after the colon. We will get the position of the colon counting from the right using the reverse function and then we will use the RIGHT function to get the text to the right of the colon.
DECLARE @string nvarchar(20) = 'Example:New'
DECLARE @position int = CHARINDEX(':',REVERSE(@string))-1
SELECT RIGHT(@string, @position) output
Additional Information

Daniel Calbimonte is a Microsoft Most Valuable Professional, Microsoft Certified Trainer and Microsoft Certified IT Professional for SQL Server. He is an accomplished SSIS author, teacher at IT Academies and has over 10 years of experience as a QE and developer for SQL Server related software. He has worked for the government, oil companies, web sites, magazines and universities around the world. Daniel also regularly speaks at SQL Servers conferences and blogs.
- MSSQLTips Awards: Author of the Year Contender – 2015-2018, 2022, 2023 | Champion (100+ tips) – 2018


