16.20 - Example: Using STRTOK - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2020-03-25
dita:mapPath
xzf1512079057909.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.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