SUBSTR in Teradata

SUBSTR or SUBSTRING function works same in Teradata. Only the syntax is different.

Syntax:

SUBSTR ( <column-name>, <start-location> [ , <length> ] )

Example:

SELECT
SUBSTR('TeradataPoint', 4 , 4),
SUBSTR('TeradataPoint', 2 , 6),
SUBSTR('TeradataPoint', 8 , 4),
SUBSTR('TeradataPoint', 4 , 8);

Output:

Substr(‘TeradataPoint’,4,4) Substr(‘TeradataPoint’,2,6) Substr(‘TeradataPoint’,8,4) Substr(‘TeradataPoint’,4,8)
adat eradat aPoi adataPoi

Length is optional here. If not specified this function will return rest all of the characters from the start location.

SELECT SUBSTR('TeradataPoint', 4 );

Output:

 *** Query completed. One row found. One column returned. 
 *** Total elapsed time was 1 second.

Substr('TeradataPoint',4)
-------------------------
adataPoint

Leave a Comment