REVERSE function |
||
This function reverses a string, just like reading it from the right to left. That is the result of the query I see the profit of this function in the following. Let we need to determine a position not the first, but the last occurrence of any character (or a sequence of characters) in a character string. Let's remind an example, where we were determining the position of the first character "a" in the name of the ship "California":
Now let's determine the position of the last occurrence of the character "a" in this name. The function CHARINDEX('a', REVERSE(name)) will allow us to find this position, but from the right. In order to get the position of this character, but from the left, it's enough to write
|