I have two tables which both contain ‘pipe separated values’
e.g:
Table 1:
DataField_A
item 1|item 2|item 3|etc.....
Table 2:
DataField_A
item 7|item 5|item 3|etc.....
I need to merge Table 2 into table 1 such that Table 2 contains all items across both tables.
Doing this pro-grammatically would be a simple matter of looping through each item in table 2 and adding to table 1 if it does not exist in table 1.
How can this be done in SQL as a stored procedure?
I’ve used a parsing function (the example I’m using comes from here) to parse the string in Table1. Then I use that function in a CTE to find missing elements in Table2 and merge the data.