How to split the string based on delimiter in Teradata

STRTOK function in Teradata

STRTOK function is used to split the string into tokens based on the specified delimiter. It returns the particular string token based on the tokennum argument.

Syntax for STRTOK function in Teradata

Input_String : A character string or String expression

Delimiter : A delimiter character. Each character in the string is considered as delimiter.If not specified, the default delimiter character is space.

tokennum : A token number to return. If not specified, the default value is 1.

STRTOK example:1 – To split the name

Here we are splitting the first name and last name from the string using STRTOK function. The delimiter character is specified as space and it returns the first name as we mentioned the token number as 1.

STRTOK example to split the first name and last name from the string

STRTOK example:2 – To split the website url

In this example, we are splitting the website URL based on the delimiter character dot(.).Since we have mentioned the token number as 2, It returns the domain name alone without www and com.

STRTOK example to split the URL in Teradata

Recommended Articles