> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# STRPOS

> Returns a substring position.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

**Aliases:** [`locate`](/query/sql/functions/string/locate)

Returns NULL if either string or a supplied start position is NULL. The start position defaults to 1.

## Syntax

### Strpos form (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
strpos(value, search[, start])
```

* Use STRING search and value operands and an INTEGER start of at least one.

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | Haystack. |
| search | STRING | Yes | Needle. |
| start | INTEGER | No | Starting character position, counted from 1. Must be an integer of at least 1; fractional positions are not supported. Default: 1. |

## Returns

* Type: BIGINT; query tools may report INTEGER
* Possible values: One-based position or zero when absent.
* NULL behavior: Returns NULL if either string or a supplied start position is NULL. The start position defaults to 1.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* INSTR uses haystack, needle; LOCATE uses needle, haystack.
* STRPOS takes the text to search first, then the substring. CHARINDEX and LOCATE take the substring first, then the text to search.

## Examples

### Alias calling form: STRPOS

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT strpos('Hello', 'll') AS "value";
```

| value |
| - |
| 3 |

### Find the first occurrence

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT strpos('banana', 'an') AS first_match, strpos('banana', 'xy') AS missing;
```

| first\_match | missing |
| - | - |
| 2 | 0 |

## Limitations

* The position is returned as BIGINT, even when query tools report INTEGER.
* Use a start position of at least 1. Zero or negative values can fail or give unexpected results. For non-ASCII text, a start position beyond the string’s length can restart the search at the beginning.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.