The CHARINDEX function is often used to search for characters or strings in a string.If the searched characters contain the characters to be searched, this function returns a non-zero integer.This integer is the number of digits at the beginning of the character to be searched. That is, the starting position of the character or string returned by the CHARINDEX function in another string.
The CHARINDEX function is called as follows:
CHARINDEX (expression1, expression2 [, start_location])
Expression1 is the character to be searched in expression2. start_location is the position where the CHARINDEX function starts to find expression1 in expression2.
Example 1:
Select CHARINDEX ('q1l ', 'HTTP: // blog.csdn.net/jiankun ')
The result is as follows:
Example 2:
Select CHARINDEX ('blog ', 'HTTP: // blog.csdn.net/jiankun ')
The result is as follows: