Rules for Using SUBSTRING() Function in SQL
- All three arguments are required in the SQL substring() function. If the starting position exceeds the maximum number of characters in the expression the SQL Server substring() function returns nothing.
- The total length can exceed the maximum character length of the original string.
- In this case, the resulting substring is the entire string from the expression start position to the expression end character.
SQL Server SUBSTRING() Function
SUBSTRING function in SQL Server is used to extract a substring from a string, starting at a specified position and with an optional length.
It is very useful when you need to extract a specific portion of a string for further processing or analysis.
SQL SUBSTRING function also works in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse.