Returns the string formed by extracting the specified number of characters from another string.
substring(expression, start, length)
select au_lname, substring(au_fname, 1, 1) from authors
select substring(upper(au_lname), 1, 3) from authors
select substring((pub_id + title_id), 1, 6) from titles
select substring(xactid,5,2) from syslogs
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.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute substring.