22 August 2018        Add to Favorites   Report

TERADATA - Finding the position of a substring in a string

We have Data : "Rj 0001 201410212014110301G 20141103ioR4564534 N20141021N 11R" 

We want to extract : "R4564534" from the string.

We basically want to extract 8 characters after "R", ignore the first occurence "Rj"

Solution:

SUBSTR(columnX,INSTR(columnX,'R',2),8)

There's already an 'R' in the first position of your string, so we are starting the scan from position 2



Read great educational content like this and a lot more ! Create my free account now 🎁

Copied