## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> CHARINDEX[CHARINDEX]:::quoted
CHARINDEX --> End((END))
```
## Purpose
The `CHARINDEX` SQL function retrieves the position with the first occurrence of a search text in another text. Search starts at the first position or, when specified, at the indicated start location.
Parameters:
- Search text: text to search for.
- Full text: text to be searched.
- Start Position (optional): start position of search.
Returns: the position of the search text inside the full text.
## Examples
The following example retrieves the position of `c` in `abcdefg`:
```sql
select charindex('c', 'abcdefg')
--------
3
```
The following example retrieves the position of `c` in `abcdefgabcdefg` starting search at position 5:
```sql
select charindex('c', 'abcdefgabcdefg', 5)
--------
10
```