
The article will explore and guide you how to use the SUBSTRING function in SQL Server to extract a substring from a specified string.
Describe
The SUBSTRING function in SQL Server allows you to extract a substring of the specified length starting from a position in the input string.
Syntax
To use the SUBSTRING function in SQL Server, we use the following syntax:
SUBSTRING(string, start, length)
Parameters :
Note :
For example
Take a look and explore some examples of SUBSTRING functions in SQL Server.
SELECT SUBSTRING('QuanTriMang.com', 1, 4);
Result: 'Quan'
SELECT SUBSTRING('QuanTriMang.com', 5, 3);
Result: 'Tri'
SELECT SUBSTRING('QuanTriMang.com', 5, 15);
Result: 'TriMang.com'
Previous lesson: STUFF function in SQL Server
Next lesson: UPPER function in SQL Server
ncG1vNJzZmismaXArq3KnmWcp51kwLau0q2poqaXYrO2usKtoKimXZ67br%2FQpWSsnaKrsrM%3D