STRTOK Function Example | Teradata Vantage - 17.10 - Example: Using STRTOK - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

Consider the following table and inserted data.

   CREATE TABLE t (id INTEGER, str VARCHAR(256));
   INSERT INTO t VALUES (1,'Teradata-Warehouse 13.10 - Combine 2 powerful forms of business intelligence (BI).'); 
   INSERT INTO t VALUES (2,'http://www.teradata.com/');

The following query returns the third token from the t.str string value. There are only two tokens in the second string, so the function returns NULL for that row.

SELECT id, STRTOK(t.str, ' -/', 3) FROM t;

The output from the query is:

         id  STRTOK(str,' -/',3)
-----------  ----------------------------------------------------------
          1  13.10
          2  NULL