SUBSTRING
string transform
What changes
- Input
- string arguments
- Output or change
- string or integer
- Return type
- Returns character data if expression is one of the supported character data types. Returns binary data if expression is one of the supported binary data types. The returned string is the same type as
Syntax at a glance
SUBSTRING ( expression , start , length )
Work example
Extract a section of a string or binary value by position.
Use a one-based start position and test empty, short, and null inputs.
Check your work SQL Server 2025 permits an omitted length, while SQL Server 2022 requires it.
Practice SQL
Open in SQL FlowSELECT SUBSTRING('TSQL', 2, 2) AS middle_chars;
Open Microsoft Learn for full syntax, permissions, and details for your version.