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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s