SUBSTRING in Teradata

SUBSTR or SUBSTRING will work same in Teradata. The syntax may be different.

Syntax:
SUBSTRING ( <column-name>, <start-location> [ , <length> ] )
or
SUBSTRING ( <column-name> FROM <start-location> FOR <length>)


Example:
SELECT
SUBSTRING('Forget code', 4 , 3),
SUBSTRING('Forget code', 1 , 6),
SUBSTRING('Forget code', 8 , 4),
SUBSTRING('Forget code', 4 , 8);

Or


SELECT
SUBSTRING('Forget code' FROM  4 FOR  3),
SUBSTRING('Forget code' FROM  1 FOR  6),
SUBSTRING('Forget code' FROM  8 FOR  4),
SUBSTRING('Forget code' FROM  4 FOR  8);


Output:
Substr('Forget code',4,3)Substr('Forget code',1,6)Substr('Forget code',8,4)Substr('Forget code',4,8)
getForgetcodeget code



The length is optional. When it is not included, all remaining characters to the end of the column are returned.

/* Substring function syntax in teardata */
SELECT SUBSTRING('Forget code' FROM 4);

Output:
Substr('Forget code',4)
get code