Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Please explain the different behavious of substr - response (2) by dnoeth

$
0
0

SUBSTR(CAST(12345 AS VARCHAR(5)),1,3)

This is an explicit cast to a VARCHAR using ANSI style syntax, which results in a left-aligned string, the result is the same as a SUBSTR('12345', 1, 3).

SUBSTR(12345,1,3)

This implicit cast to a VARCHAR using Teradata style syntax, which results in a right-aligned string based on the FORMAT. 12345 is a SMALLINT with a FORMAT '-(5)9', up to five digits and a leading sign, the result is the same as a SUBSTR(' 12345', 1, 3).
 
Dieter


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>