CHARINDEX
CharIndex returns the first occurance of a string or characters within another string. The Format of CharIndex is given Below:
CHARINDEX ( expression1 , expression2 [ , start_location ] )
CharIndex returns the first occurance of a string or characters within another string. The Format of CharIndex is given Below:
CHARINDEX ( expression1 , expression2 [ , start_location ] )
Here expression1 is the string of characters to be found within expression2.
So if you want to search ij within the word Wilson, we will use il as expression1 and Wilsonas expression2.
start_location is an optional integer argument which identifies the position from where the string will be searched. Now let us look into some examples :
SELECT CHARINDEX('SQL', 'Microsoft SQL Server')
OUTPUT:
11
SELECT CHARINDEX('SQL', 'Microsoft SQL Server')
OUTPUT:
11
No comments:
Post a Comment