The rightmost part of the expression with the specified number of characters.
right(expression, integer_expr)
is a character or binary-type column name, variable, or constant expression of char, varchar, nchar, unichar, nvarchar, univarchar, binary, or varbinary type.
is any integer (tinyint, smallint, or int) column name, variable, or constant expression.
select right("abcde", 3)
--- cde
select right("abcde", 2)
-- de
select right("abcde", 6)
----- abcde
select right(0x12345000, 3)
------- 0x345000
select right(0x12345000, 2)
------ 0x5000
select right(0x12345000, 6)
--------- 0x12345000
right, a string function, returns the specified number of characters from the rightmost part of the character or binary expression.
If the specified rightmost part begins with the second surrogate of a pair (the low surrogate), the return value starts with the next full character. Therefore, one less character is returned.
The return value has the same datatype as the character or binary expression.
If expression is NULL, right returns NULL.
For general information about string functions, see “String functions”.
ANSI SQL – Compliance level: Transact-SQL extension
Any user can execute right.