SUBSTRING () is the most commonly used function in the SQL Server to find the substring of a given string in other words to get some part of a string in your query.
It takes three parameters; first is the string from which the substring has to be found, second is the start position from where the substring has to start and three is the length of the substring.
In other words, function will start extracting the substring from the start position which is given and will show the substring which is till the given length next to the start position.
Syntax:
SUBSTRING(string, start_position, lengthofthesubstring)
Example:
SELECT
Result = SUBSTRING('test string', 6, 3)
Output:
Substring
--------------
str
It should also be noted that SUBSTRING() function is not only used with string datatype but also for ntext, VARCHAR and CHAR datatypes