String Functions – REVERSE()


I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the REVERSE() function today.

The REVERSE() function takes a source string as input and returns each character in the reverse order as output. Therefore, the last character input string is now the first character in the output string. And the first character in the input string is last character in the output string.

Let’s have some fun by using palidromes in the next example. The example below has two words that become other words when reverse. This is usually not the case. Most of the time, a reversed word is gibberish.

One thing to always worry about when using TSQL functions is how will it react with a EMPTY strings or NULL values? Both empty strings and NULL values as input return themselves as output.

Next time, I will be exploring the RIGHT() function.

Related posts

Leave a Comment