I want to extract values from a column value in string with repetitive character "-".
For Ex : this is the string VAL1 = ALPHABET-ABC-PQRST-DEFGH
For the mentioned string, i am trying to get values between the "hyphens".
First column i am able to get : SUBSTRING(VAL1,0,CHARINDEX('-',VAL1) as Column1 which is ALPHABET
How can i get further values like ABC, PQRST and DEFGH. I have been trying with:
SUBSTRING(VAL1,CHARINDEX('-',VAL1)+1,PATINDEX('%-%',VAL1)) as Column2
which is not working. Kindly help.