Example: Differences Between SUBSTR and SUBSTRING - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantage™

Consider the following table:

   CREATE TABLE ctable1
     (c1 VARCHAR(11) CHARACTER SET KANJI1);

The following table shows the difference between SUBSTR and SUBSTRING in Teradata mode for KANJI1 strings from KanjiEBCDIC client character set.

IF c1 contains … THEN this query … Returns …
MN<ABC >P SELECT SUBSTR(c1,2) FROM ctable1; N<ABC>P
SELECT SUBSTR(c1,3,8) FROM ctable1; <ABC>
SELECT SUBSTR(c1,4) FROM ctable1; ABC >P
The client application might not be able to properly interpret the resulting multibyte characters because the shift out (<) is missing.
SELECT SUBSTRING(c1 FROM 2)

FROM ctable1;

N<ABC>P
SELECT SUBSTRING(c1 FROM 3 FOR 8)

FROM ctable1;

<ABC>P
SELECT SUBSTRING(c1 FROM 4)

FROM ctable1;

<BC>P