SQL REVERSE() Function


The SQL REVERSE() is a function, and returns a string in which the character order of a specified string is reversed.

The SQL REVERSE() function is supports character based column and numeric based columns.

It can be used in any valid SQL SELECT statement as well in SQL where clause.

You can also search these topics using sql reverse function, sql reverse order, how to reverse a string, sql character functions, find character in string sql, sql char function.

SQL REVERSE() Syntax

For Sql Server / MY SQL


//  Reverse a input string or text expression

SELECT REVERSE(string or text);

//  Reverse a specific table column value

SELECT REVERSE(column_name1) FROM table_name;

For MS Access


//  Reverse a input string or text expression

SELECT STRREVERSE(string or text);

//  Reverse a specific table column value

SELECT STRREVERSE(column_name1) FROM table_name;


SQL REVERSE() Example - Using Expression Or Formula

The following SQL SELECT statement will convert of a given input string to lowercase:

For SQL SERVER / MySql


SELECT REVERSE('SimmanChith.COM') AS 'Reversed String';

For MS Access


SELECT STRREVERSE('SimmanChith.COM') AS 'Reversed String';

The result of above query is:

Reversed String
MOC.htihCnammiS

SQL REVERSE() Function More Example

Input Value Result
REVERSE('Hi! Welcome') emocleW !iH
REVERSE('123456') 654321
REVERSE('Sql DataBase Tutorial 2.0') 0.2 lairotuT esaBataD lqS

Sample Database Table - Books

BookId BookName BookPrice RelYear DomainName AuthorName
1 Advanced SQL Programming 178.69 2015 Security Hanumanthan
2 Professional Oracle 160 2007 Optimization Devi Mai
3 A Visual Introduction To Sql 125 2006 Security Ranjani Mai
4 Oracle Concurrency 155 2008 Optimization Hanumanthan

SQL REVERSE() Example

The following SQL statement selects the "BookName" and "BookPrice" fields from the "Books" table, and display the column text in reverse order.

For SQL SERVER / MySql


SELECT 
REVERSE(BookName) As 'Reversed Book Name',
REVERSE(BookPrice) As 'Reversed Book Price'  
FROM Books;

For MS Access


SELECT 
STRREVERSE(BookName) As 'Reversed Book Name',
STRREVERSE(BookPrice) As 'Reversed Book Price'  
FROM Books;

The result of above query is:

Reversed Book Name Reversed Book Price
gnimmargorP LQS decnavdA 96.871
elcarO lanoisseforP 061
lqS oT noitcudortnI lausiV A 521
ycnerrucnoC elcarO 551
You can also search these topics using pl sql program to reverse a string, sql server reverse, string functions sql, sql string functions with examples, sql query string functions, sql string functions examples.