REVERSE Function in SQL Server

Reverse Function: Reverse function is used to reverse the text provided to the command.

Using reverse function you can not only reverse the content but also along with the CharIndex function you can extract the substring as you are extracting by finding the last index in other programming language.

Example:

Select REVERSE(‘E:\ABC\PQR\Test.txt’) Rev, REVERSE(SUBSTRING(REVERSE(‘E:\ABC\PQR\Test.txt’),0,CHARINDEX(‘\’,REVERSE(‘E:\ABC\PQR\Test.txt’)))) FileName

Output:

 

Reverse

 

Advertisements

#reverse-function