substring

Returns the string formed by extracting the specified number of characters from another string.

Syntax

substring(expression, start, length)

Parameters

Examples

Usage

  • substring, a string function, returns part of a character or binary string. For general information about string functions, see Transact-SQL Users Guide.

  • If substring’s second argument is NULL, the result is NULL. If substring’s first or third argument is NULL, the result is blank..

  • If the start position from the beginning of uchar_expr1 falls in the middle of a surrogate pair, start is adjusted to one less. If the start length position from the beginning of uchar_expr1 falls in the middle of a surrogate pair, length is adjusted to one less.

See also Transact-SQL Users Guide.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute substring.

Related reference
charindex
patindex
stuff