Substring TSQL Tutorial

Substring function

States table:

STATE_IDNAME
1Arizona
2California
3Texas
4Michigan

Substring Example:

SELECT Name, SUBSTRING(name, 1, 1) AS Initial, SUBSTRING(name, 1, 3) AS Short_name
FROM states;

Substring Result:

NameInitialShort_name
ArizonaAAri
CaliforniaCCal
TexasTTex
MichiganMMic

See also: T-SQL Functions -> Patindex | Replace | Right | Rtrim | Upper