22 Aug 18 · npack ·       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


npack

posted on 22 Aug 18

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied