I have strings like
OPEN SYSTEMS SUB GR (GM/BTIB(1111)/BTITDBL(2222)/BTVY(4444)/ACSVTYSAG)
in my database under my GROUPS Column.
What I want to do is to extract the 2222 from that string. The code I am using is like that.
SELECT
SUBSTRING(GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS,0)+1)+1)+1, 4 ) AS GroupNo
FROM MY_TABLE
WHERE
ISNUMERIC(SUBSTRING(GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS,0)+1)+1)+1, 4 )) = 1
I need to fasten the above code up, by either changing the substring way I am using , or changing some logic. Can you tell me what things can be improved in my code ?