Returns the part of a character string starting a specified number of integer_expression characters from the right.
RIGHT(character_expression, integer_expression)
varchar
character_expression must be of a data type that is implicitly convertible to varchar. Otherwise, use CAST to explicitly convert character_expression.
Compatibility levels can affect return values. For more information, see sp_dbcmptlevel.
This example returns the five right-most characters of each author’s first name.
USE pubs
GO
SELECT RIGHT(au_fname, 5)
FROM authors
ORDER BY au_fname
GO
Here is the result set:
-----
raham
Akiko
lbert
Ann
Anne
Burt
rlene
heryl
Dean
Dirk
ather
Innes
hnson
Livia
jorie
ander
chael
ichel
gstar
inald
heryl
earns
ylvia
(23 row(s) affected)
CAST and CONVERT | String Functions |
Data Types |