RIGHT Function [String]

Returns the rightmost characters of a string.

Syntax

RIGHTstring-expression, numeric-expression )

Parameters

Parameter

Description

string-expression

The string to be left-truncated.

numeric-expression

The number of characters at the end of the string to return.

Returns

LONG VARCHAR

LONG NVARCHAR

Note: The result data type is a LONG VARCHAR. If you use RIGHT in a SELECT INTO statement, you must have an Unstructured Data Analytics Option license or use CAST and set RIGHT to the correct data type and size.

Example

The following statement returns the value “olate:”

SELECT RIGHT( 'chocolate', 5 ) FROM iq_dummy

Usage

If the string contains multibyte characters, and the proper collation is being used, the number of bytes returned might be greater than the specified number of characters.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
LCASE Function [String]
LEFT Function [String]
LOWER Function [String]
REPLACE Function [String]
REVERSE Function [String]
UCASE Function [String]
UPPER Function [String]