Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » String FunctionsRSS Feeds

REVERSE Function

Posted By: Sarita Patel     Category: SQL Server     Views: 3110

This article explains REVERSE function of sql server with examples.

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. 
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on REVERSE Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of REVERSE Function is from United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!