Skip to main content

CHARINDEX() Function

Definition CHARINDEX() is a function that accepts two arguments. The first argument is the character you are searching for; the second is the string. It will return the first index position that the c

Updated over 2 weeks ago

Definition

CHARINDEX() is a function that accepts two arguments. The first argument is the character you are searching for; the second is the string. It will return the first index position that the character passed into the first argument is within the string.

Syntax

CHARINDEX(stringToFind, stringToSearchFor, startLocation )

where stringToFind and stringToSearchFor are required fields. startLocation is optional and it is the position where the search will start (if you do not want to start at the beginning of string). The first position in string is 1.

Example(s)

What to use in Custom SQL field:

  • CHARINDEX(' ',[Assignment Derived Calculations: Employee First Last Name])

Field Outputs:

mceclip1.png

From the output you can see, the position of the space within [Assignment Derived Calculations: Employee First Last Name] in the second column. CHARINDEX can be a useful function for finding occurrences of a character within a table programmatically.

Did this answer your question?