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.


Search Keys

  • sql reverse function
  • reverse sql
  • string reverse
  • 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
5 SQL Server 2012 Black Book 99.99 2011 Security Padmavathi
6 The Complete Guide to Oracle 175 2008 Programming Vinoth Kumar
7 SQL Server Database Internals 110 2009 Programming Chandra
8 Programming With MySQL 60 2015 Performance Varshini Kutty
9 SQL Design Patterns 95 2008 Performance Ramanathan
10 Programming With Sql Server T-Sql 190 2007 Administration Dharan
11 Troubleshooting MYSQL 185 2006 Security Vinoth Kumar
12 Oracle Cookbook 140 2013 Database Balan

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
kooB kcalB 2102 revreS LQS 99.99
elcarO ot ediuG etelpmoC ehT 571
slanretnI esabataD revreS LQS 011
LQSyM htiW gnimmargorP 06
snrettaP ngiseD LQS 59
lqS-T revreS lqS htiW gnimmargorP 091
LQSYM gnitoohselbuorT 581
koobkooC elcarO 041

Search Keys

  • reverse string
  • mssql reverse
  • 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