SUBSTRING a return part of a string. SUBSTRING is used to get a part of a string from the original string. SUBSTRING not only work on string or text data, SUBSTRING work on binary or image data also. SUBSTRING always return a part of string , text , binary or image data which was supplied to it.Here is the list of data type that support SUBSTRING.
If you supply a binary data type to the SUBSTRING, SUBSTRINGreturn binary, if you supply sting, SUBSTRINGwill return string. The same scenario happen for text , image data also.
Syntax :
SUBSTRING ( stringn ,start_position , length )
string : The source string on which SUBSTRING will be applied.
start_position : The position , from where start extraction.
length : The number of characters to be extracted.
Below are the example of SUBSTRING from different position to different length. The data supplied is string and return also string.
Example 1
SELECT
SUBSTRING('Hellow
World',8,5)
Result:
World
Example 2
SELECT
SUBSTRING('Hellow
World',0,6)
Result:
Hello
Example 3
SELECT
SUBSTRING('Hellow
World',7,1)
Result:
''
No comments:
Post a Comment