How to split a string value based on a delimiter in DB2

Short answer: You need to find the position of the delimiter, and then substring using it as the starting point, and a calculated length. SELECT SUBSTR(‘CHG-FFH’, 1, LOCATE(‘-‘,’CHG-FFH’)-1) as FIRST_PART , SUBSTR(‘CHG-FFH’, LOCATE(‘-‘,’CHG-FFH’)+1) as SECOND_PART FROM SYSIBM.SYSDUMMY1; BONUS! If you do this often, create a user defined function to do it dynamically. Here’s an example … Read more