Reverse Function in SQL Server reverses a string and returns the result. It is a useful function that reverses the input string in SQL Server. In this article, we will discuss the SQL Reverse Function. Also, we will discuss a few examples of using it.
Syntax
REVERSE (string)
Parameters
The function expects only one parameter. You need to pass the string you want to reverse in the parameters.
Return Value
The Reverse Function returns a string which is the reverse of the original input string.

Support
The function works in SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse.
Examples
Let’s discuss a few examples of using the function in SQL Server.
Example 1: Basic Usage
SELECT REVERSE('Concatly'); +---------------------+ | REVERSE('Concatly') | +---------------------+ | yltacnoC | +---------------------+
You can reverse a string in SQL Server by passing it in the reverse function as above. The function returns the reverse of the original string.
Example 2: SELECT Query
You can reverse a column’s value from a table using the Reverse Function as follows:
select user_name, REVERSE(user_name) as reverseUser from users; +---------------+---------------+ | user_name | reverseUser | +---------------+---------------+ | Vishesh Ahuja | ajuhA hsehsiV | | Vishesh | hsehsiV | | Rishabh | hbahsiR | | Rishabh | hbahsiR | | Example | elpmaxE | | Chin | nihC | +---------------+---------------+
Example 3: UPDATE Query
Also, you can use the function in an update query to update the existing columns in a table.
UPDATE users SET user_name = REVERSE(user_name); Query OK, 6 rows affected (0.05 sec) Rows matched: 6 Changed: 6 Warnings: 0 mysql> SELECT user_name from users; +---------------+ | user_name | +---------------+ | ajuhA hsehsiV | | hsehsiV | | hbahsiR | | hbahsiR | | elpmaxE | | nihC | +---------------+
Conclusion
In this article, we discussed the SQL Reverse Function. You can learn more about it on the Official Microsoft Documentation. Also, you can learn about more SQL String Functions on Concatly.

Vishesh is currently working as a Lead Software Engineer at Naukri.com. He passed out of Delhi College of Engineering in 2016 and likes to play Foosball. He loves traveling and is an exercise freak. His expertise includes Java, PHP, Python, Databases, Design and Architecture.