The CHARINDEX and PATINDEX functions return the
starting position of a pattern you specify. PATINDEX can use wildcard
characters, but CHARINDEX cannot.
These functions take two parameters:
· The pattern whose position you want. With PATINDEX,
the pattern is a literal string that can contain wildcard characters. With
CHARINDEX, the pattern is a literal string without wildcard characters.
·
A string-valued expression, generally a column name,
searched for the specified pattern.
SELECT CHARINDEX('JA','VIJAY')
O/P :- 3
SELECT PATINDEX('%GMAIL%','VIJAYK0286@GMAIL.COM')
O/P :- 12
SELECT PATINDEX('%GM__L%','VIJAYK0286@GMAIL.COM')
O/P :- 12