I've tried to find a solution that does this...I need to split a string that is in a column, to produce one entry per value, retaining the existing column values.
Example:
CREATE TABLE #SplitMeUp(
SomeInt INT NOT NULL
, SomeName VARCHAR(10) NOT NULL
, LongList VARCHAR(100) NOT NULL
)
INSERT INTO #SplitMeUp VALUES (1,'First', 'A,B,C,D')
INSERT INTO #SplitMeUp VALUES (2,'Second', 'B,C,D,E,F,G')
INSERT INTO #SplitMeUp VALUES (3,'Third', 'A')
INSERT INTO #SplitMeUp VALUES (4,'Fourth', 'A,B,C,D,E,F,G')
SELECT * FROM #SplitMeUp
1 First A,B,C,D
2 Second B,C,D,E,F,G
3 Third A
4 Fourth A,B,C,D,E,F,G
I am trying to achieve the following, but I can't use a function as I don't have permissions, on 2012 so can't use STRING_SPLIT
and the solutions I have found just split the actual string, not retain the other values.
1 First A
1 First B
1 First C
1 First D
2 Second B
2 Second C
2 Second D
2 Second E
2 Second F
2 Second G
3 Third A
4 Fourth A
4 Fourth B
4 Fourth C
4 Fourth D
4 Fourth E
4 Fourth F
4 Fourth G