charindex

Function

result = charindex(needle, haystack, [start])

Arguments

ArgumentData Type
needlestring
haystackstring
startinteger
resultinteger

Comments

This function searches for the needle string , in the haystack string, and returns the starting position if found or zero if not found. If the start parameter is less than 1 then the search starts from the beginning of the haystack string. haystack is limited to 8000 characters.

Examples

result = charindex('boson', 'Higgs boson experiment') /* result = 7 */
result = charindex('boson', 'Milgram experiment') /* result = 0 */