Q:

Text string split\cut

|
I have many strings that need to be cut\split according to one basic rule - split\ cut between the 1st ";" to the 2nd ";" and than paste it under new column.
for examples one of my rows data is:
 Y 4+2 A SAMPLES; Res 50Xp3 TP; HRI ; Bin n/a; Skew: RS; Source: Y805 [100] (Qty 100);

from this row I should retrieve: "Res 50Xp3 TP"
I think I tried all split option without success I also tried to use PATINDEX\CHARINDEX and it didn't help.
Thanks,

A:

i've done things like this in my scripts using combination of CHARINDEX and SUBSTRINGs
DECLARE @str VARCHAR(200) = 'Y 4+2 A SAMPLES; Res 50Xp3 TP; HRI ; Bin n/a; Skew: RS; Source: Y805 [100] (Qty 100)'
DECLARE @char VARCHAR(1) = ';'

SELECT 
    SUBSTRING(
            LTRIM(SUBSTRING(@str,CHARINDEX(@char, @str)+1, LEN(@str)-CHARINDEX(@char, @str))),
            0,
            CHARINDEX(@char, LTRIM(SUBSTRING(@str,CHARINDEX(@char, @str)+1, LEN(@str)-CHARINDEX(@char, @str))))
            )

output
Res 50Xp3 TP

in reference to the comments
SELECT 
    SUBSTRING(
            LTRIM(SUBSTRING(v.description,CHARINDEX(';', v.description)+1, LEN(v.description)-CHARINDEX(';', v.description))),
            0,
            CHARINDEX(';', LTRIM(SUBSTRING(v.description,CHARINDEX(';', v.description)+1, LEN(v.description)-CHARINDEX(';', v.description))))
            ) AS 'YourText'
FROM vw_public_vpo AS v

