REVERSE function is used to reverse a string expression.
Syntax of REVERSE Function :
REVERSE ( character_expression )
character_expression is an expression to replace a string. It can be a constant, variable, or column of type character or binary data.
Return type of REVERSE function is varchar.
Examples of REVERSE Function :
Example 1 : Use of REVERSE function in select clause
SELECT REVERSE('Syntax-Example')
Output
elpmaxE-xatnyS
Above example returns reversed string of a specified string.
Example 2 : Use of REVERSE function to display field value in reverse of table.
SELECT REVERSE(ContactName) AS 'Reversed Name'
FROM Customers
Output
Reversed Name
srednA airaM
ollijurT anA
oneroM oinotnA
ydraH samohT
dnulgreB anitsirhC
sooM annaH
Above example displays customer name in reverse order.