right

Description

Returns the part of the character or binary expression starting at the specified number of characters from the right. Return value has the same datatype as the character expression.

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

Documentation Transact-SQL Users Guide

Functions rtrim, substring