What is charindex in sql?


Charindex is used to search an expression in another expression and return its starting position if found else will return 0.
Syntax :
CHARINDEX ( expression_ToFind ,expression_ToSearch)
Example :

 
DECLARE @expression_ToSearch varchar(100);
SELECT  @expression_ToSearch = 'I am proud to be an Indian.';
SELECT CHARINDEX('be', @expression_ToSearch);


Result : 15