The RIGHT()
function returns a specific number of characters from the right side of a string.
Figure 1 shows a visual representation of the RIGHT()
function.
RIGHT(string, numOfChars)
The RIGHT()
function requires two parameters:
If a number instead of a string is sent as a parameter, then the number will be cast to a string and then the function will be applied.
The RIGHT()
function returns the specific number of characters from the right side of a string sent as a parameter.
If the number of characters is greater than the actual length of the string, then the function returns the entire string.
-- string sentSELECT RIGHT('HELLO',3);-- number of characters greater than length of stringSELECT RIGHT('HELLO',7);-- number is sent instead of string-- it will be cast as a string and then right() is appliedSELECT RIGHT(12345,2);