SPLIT_PART

functionsupportedCore SQL functions

docs.snowflake.com ↗

String & binary functions

Splits a given string at a specified character and returns the requested part. To return all characters after a specified character, you can use the POSITION and SUBSTR functions. For an example, see Returning substrings for email, phone, and date strings. Tip You can use the search optimization service to improve the performance of queries that call this function. For details, see Search optimization service. See also: SPLIT, STRTOK

Syntax

SPLIT_PART(<string>, <delimiter>, <partNumber>)

Parameters

NameRequiredDescription
stringrequiredText to be split into parts.
delimiterrequiredText representing the delimiter to split by. The entire delimiter string is treated as a single delimiter, even if it contains multiple characters. This behavior differs from STRTOK, which treats each character in the delimiter as a separate delimiter.
partNumberrequiredRequested part of the split, which is 1-based so that the first token is token number 1, not token number 0. If the value is negative, the parts are counted backward from the end of the string.

Returns

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

Usage notes

Collation details

The collation specifications of all input arguments must be compatible. This function does not support the following collation specifications: - pi (punctuation-insensitive). - cs-ai (case-sensitive, accent-insensitive).

Referenced by