I want to split the column’s string, and based on the string parts execute multiple inserts in a different table.
Table Employee
:
ID | NAME |
---|---|
1 | John;Josh;Brad |
2 | Mark;Ross |
Table Employee_Names
should end up like this:
ID | EMP_ID | NAME |
---|---|---|
1 | 1 | John |
2 | 1 | Josh |
3 | 1 | Brad |
4 | 2 | Mark |
5 | 2 | Ross |
I tried some magic with the STRING_SPLIT
function but wasn’t able to complete the work. I followed these instructions: https://codingsight.com/several-ways-to-insert-sql-split-strings-in-a-column/.
The version is: Microsoft SQL Azure (RTM) – 12.0.2000.8
3