Avatar of PresidentLincoln
PresidentLincoln
Flag for United States of America asked on

DB2: Need to extract specific characters left of delimiter in string

I am using Data Studio to write a query for a DB2 AIX database.  I have a small issue I'm running into.  

I have a column that appears like this:

SBN:123456=1
SBN:1234=0
SBN:12345678=5

Open in new window


I need to extract all characters, starting from the "SBN", all the way up to, but not including, the equal sign.  The numbers after "SBN" can be of varying length, so I just need the beginning of the string up until the equal sign.  What is the easiest way to accomplish this?
DatabasesDB2

Avatar of undefined
Last Comment
PresidentLincoln

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Member_2_2484401

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
PresidentLincoln

ASKER
@Dave Ford, I did try something similar to this earlier (I should probably append my original comment), and then I tried your code, and I received the error "The statement was not executed because a numeric argument of a scalar function is out of range - SQLCODE 138" in both instances.  Any ideas why I'm getting that?  I isolated that piece of code from the query to try and figure it out, but I'm still getting that error using just what you posted.
PresidentLincoln

ASKER
Looks like my issue was caused by some NULLs.  Got rid of those and it works well.  Thanks!
Your help has saved me hundreds of hours of internet surfing.
fblack61