How to split list of values into multiple rows after semi-colon? I'm thinking this is easy, but I'm having a hard time manifesting. I have a list of values, e.g.
@bob
@sarah
@kelly;john
@denver_colorado
@james12;kellybelly
I want the list to be:
@bob
@sarah
@kelly
@john
@denver_colorado
@james12
@kellybelly
essentially, splitting a line after &quot;;&quot; and add @ as a prefix to all values
Use the SPLIT_STRING function to separate the string on each ';'
Use the REPLACE function to change all '@' to a ';' so this also signals a split.
Prefix the value with '@'
declare @s nvarchar(max) 

set @s = '@bob
@sarah
@kelly;john
@denver_colorado
@james12;kellybelly'

SELECT '@' + value
FROM SPLIT_STRING(REPLACE(@string, '@', ';'), ';')