RIGHT (SQL)
Synopsis
{fn RIGHT(string-expression,count)}
Description
RIGHT returns count number of characters from the end (rightmost position) of string-expression. RIGHT returns NULL if passed a NULL value for either argument.
RIGHT can only be used as an ODBC scalar function (with the curly brace syntax).
Arguments
string-expression
A string expression, which can be the name of a column, a string literal, or the result of another scalar function, where the underlying data type can be represented as any character type (such as CHAR or VARCHAR).
count
An integer that specifies the number of characters to return from the ending (rightmost) position of string-expression.
Examples
The following example returns the two rightmost characters of each name in the Sample.Person table:
SELECT Name,{fn RIGHT(Name,2)}AS MiddleInitial
FROM Sample.Person
The following example shows how RIGHT handles a count that is longer than the string itself:
SELECT Name,{fn RIGHT(Name,40)} FROM Sample.Person
No padding is performed.