Example: Using STRTOK

Teradata Database SQL Functions, Operators, Expressions, and Predicates

brand
Software
prodname
Teradata Database
vrm_release
16.10
category
Programming Reference
featnum
B035-1145-161K

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