POSITION

functionsupportedCore SQL functions

docs.snowflake.com ↗

String & binary functions

Searches for the first occurrence of the first argument in the second argument and, if successful, returns the position (1-based) of the first argument in the second argument. If you need to find the position beyond the first occurrence (for example, the third occurrence), you can use the REGEXP_INSTR function. Aliases: CHARINDEX Note that the CHARINDEX function does not support one of the syntax variations that POSITION supports.

Syntax

supportedpartialnot supportednot scored

POSITION( <expr1>, <expr2> [ , <start_pos> ] )

POSITION( <expr1> IN <expr2> )

Parameters

NameRequiredDescription
expr1requiredA string or binary expression representing the value to look for.
expr2requiredA string or binary expression representing the value to search.
start_posoptionalA number indicating the position at which to start the search (with 1 representing the start of expr2). Default: 1

Returns

This function returns a value of type NUMBER. If any argument is NULL, the function returns NULL.

Usage notes

Collation details

This function does not support the following collation specifications: - pi (punctuation-insensitive). - cs-ai (case-sensitive, accent-insensitive).