Find position of a string in SQL Server

The char index function will return the position of the string. It will always return the first position and its occurrence based on the start position we mention

select charindex('s','jesus',0)
select charindex('s','jesus',4)

 

The first select will return 3 starting position is 0

The second select will return 5. It will ignore first occurrence since starting position is 4.

Find position of a string in SQL Server was last modified: October 1st, 2017 by Justin Antony