CHARINDEX – Return a starting position in a specific character – Character Functions

CHARINDEX returns the position of a specific character. For example, if you want the position of “d” from “Windows”, CHARINDEX returns “4″ because d is positioned 4th character of “Windows”. CHARINDEX is case insensitive.

example: Return the position of “d”.

SELECT word, CHARINDEX(’d', word) FROM tbTestTable;

word                CHARINDEX(word)
Windows                     4
Mac                           0
development                1
FLOPPYDISK                 7

example: Return the position of “w” from 3rd character of a string.

SELECT word, CHARINDEX(’w', word, 3) FROM tbTestTeble;

word            CHARINDEX(word)
Windows       6
weekend       0 

Posted in Character Functions