right

Description

The rightmost part of the expression with the specified number of characters.

Syntax

right(expression, integer_expr)

Parameters

expression

is a character or binary-type column name, variable, or constant expression of char, varchar, nchar, unichar, nvarchar, univarchar, binary, or varbinary type.

integer_expr

is any integer (tinyint, smallint, or int) column name, variable, or constant expression.

Examples

Example 1

select right("abcde", 3)
 ---
 cde

Example 2

select right("abcde", 2)
 --
 de

Example 3

select right("abcde", 6)
 -----
 abcde 

Example 4

select right(0x12345000, 3)
 -------
 0x345000

Example 5

select right(0x12345000, 2)
 ------
 0x5000

Example 6

select right(0x12345000, 6)
 ---------
 0x12345000

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension

Permissions

Any user can execute right.

See also

For general information about string functions, see “String functions”.

Functions rtrim, substring