Skip to content
Related Articles

Related Articles

REVERSE() Function in SQL Server

View Discussion
Improve Article
Save Article
  • Last Updated : 30 Dec, 2020
View Discussion
Improve Article
Save Article

REVERSE() function :
This function in SQL Server is used to reverse the stated string and return the output.

Features :

  • This function is used to reverse the stated string.
  • This function accepts strings as parameter.
  • This function always returns string.
  • This function can also take set of integers and reverse it.
  • This function can even reverse float values.

Syntax :

REVERSE(string)

Parameter :
This method accepts only one parameter as given below :

  • string : Specified string to be reversed.

Returns :
It returns the stated string in the reversed form.

Example-1 :
Getting the reversed string of the specified string.

SELECT REVERSE('gfG');

Output :

Gfg

Example-2 :
Using REVERSE() function with a variable and getting the reversed string of the specified string.

DECLARE @string VARCHAR(15);  
SET @string = 'geeksforGeeks';  
SELECT REVERSE(@string);

Output :

skeeGrofskeeg

Example-3 :
Getting the reversed string of a set of integers.

SELECT REVERSE(123);

Output :

321

Example-4 :
Getting the reversed string of a float value.

SELECT REVERSE(1.56);

Output :

65.1

Application :
This function is used to reverse the specified string and then return it as output.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!