The arguments to the RIGHT function cannot be user-defined
data types.
In left-to-right locales, such as the default U.S.
English locale, this function returns a substring of trailing characters
from the source_string.
What the RIGHT function returns depends on the
number of logical characters in source_string and on the value
of position:
If source_string evaluates to a string with more than position characters,
the return value is a substring of source_string, consisting
of all characters to the right of the specified position.
If source_string evaluates to a string with no more than position characters,
the return value is the entire source_string.
If source_string evaluates to NULL, or if position is
zero or negative, then NULL is returned.
If no position argument is specified, no string value is
returned, and an exception is issued.
The return data type is the same as its source_string argument.
If a host variable is the source, the return value is either NVARCHAR
or NCHAR, according to the length of the returned string, using the
return type promotion rules that the section Return Types from the CONCAT
Function describes.
The following function expression requests the last five
characters of a quoted string:
RIGHT('www.ibm.com',5)
In
this example, the RIGHT function returns the substring m.com