I have data stored such that my query returns the following:
EntryNum FieldNames FootnoteIDs
1 FieldA, FieldA, FieldB F1, F3, F2
2 FieldA, FieldA, FieldB F1, F4, F2
3 FieldB, FieldC, FieldD F1, F12, F13
I'd like to return this as follows:
EntryNum FieldName FootnoteID
1 FieldA F1
1 FieldA F3
1 FieldB F2
2 FieldA F1
2 FieldA F4
2 FieldB F2
3 FieldB F1
3 FieldC F12
3 FieldD F13
What would the SQL for this look like? Is it doable without using either a user-defined function or SPLIT_STRING?
The closest I found to a solution was here: Split comma separated string table row into separate rows using TSQL, but that doesn't have the dual splitting behavior I need. Further details a) there isn't a limit to the number of fields per Entry or FootnoteIDs per entry, and b) it's just the order of the FieldNames and FootnoteIDs that I need matched.