16.20 - Example: Using STRTOK - Teradata Database

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

prodname
Advanced SQL Engine
Teradata Database
vrm_release
16.20
created_date
March 2019
category
Programming Reference
featnum
B035-1145-162K

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