CHARINDEX

CHARINDEX function searches for one string inside a second string expression, returning the starting position of the first expression if found. If not found a 0 is returned.

Syntax

CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] ) 

Example

SELECT CHARINDEX(‘an’, ‘This is an example’) as PositionofAN

The above query returns:

PositionofAn
------------------
9