SQL Server SUBSTRING Function By Practical Examples | sql substring index
Summary:inthistutorial,youwilllearnhowtousetheSQLServerSUBSTRING()functiontoextractasubstringfromastring.SQLServerSUBSTRING()functionoverviewTheSUBSTRING()extractsasubstringwithaspecifiedlengthstartingfromalocationinaninputstring.ThefollowingshowsthesyntaxoftheSUBSTRING()function:SUBSTRING(input_string,start,length);Inthissyntax:input_stringcanbeacharacter,binary,text,ntext,orimageexpression.startisanintegerthatspecifiesthelocationwherethereturnedsubstringstarts.Notethatthefirstcharacterinth...
Summary: in this tutorial, you will learn how to use the SQL Server SUBSTRING() function to extract a substring from a string.
SQL Server SUBSTRING() function overviewThe SUBSTRING() extracts a substring with a specified length starting from a location in an input string.
The following shows the syntax of the SUBSTRING() function:
SUBSTRING(input_string, start, length);
In this syntax:
input_string can be a character, binary, text, ntext, or image expression.start is an integer that specifies the location where the returned substring starts. Note that the first character in the input_string is 1, not zero.length is a positive integer that specifies the number of characters of the substring to be returned. The SUBSTRING() function raises an error if the length is negative. If start + length > the length of input_string, the substring will begin at the start and include the remaining characters of the input_string.SQL Server SUBSTRING() examplesLet’s ...