Home > database >  How to split a string by delimter ";" to rows without using STRING_SPLIT function
How to split a string by delimter ";" to rows without using STRING_SPLIT function

Time:04-14

I would like to know if there are any other alternative to splitting a string by its ";" delimiter into separate rows without using the STRING_SPLIT function or CREATE or WITH.

The original data looks as follows:

ID       STRING
1        a;b;c
2        e;f
3        e;f;g;h

And I would like to see it in this form:

ID       STRING
1        a
1        b
1        c
2        e
2        f
3        e
3        f
3        g
3        h

CodePudding user response:

FOR SQL SERVER you can use this or try similar queries as you didn't specified database name.

REVERSE(PARSENAME(REPLACE(REVERSE(STRING), ',', '.'), 1))

CodePudding user response:

  • select id, value as string from yourtable cross apply string_split(string,';')
  • Related