0

I need a way to parse out data that contains multiply values in the same column. The values are separated by pipe delimiters.

Any help on how to achieve this in SQL would be great.

Current Table:

'''

Expected outcome needed:

''' enter image description here

Alan Paul
  • 91
  • 6
  • 1
    You are not respecting 1NF *"Each table cell must contain a single value"*. This is the first rule on Database Normalization. Check this [1NF Wikypedia](https://en.wikipedia.org/wiki/First_normal_form) – 0xNIC Mar 03 '23 at 11:14
  • Your question is very similar to [this](https://stackoverflow.com/a/75580192/9961286) – 0xNIC Mar 03 '23 at 11:16
  • yep I understand the 1NF rule but I have a dataset that contains pipe delimiters in more than 1 column so i need to see if there is a way to normalize it – Alan Paul Mar 03 '23 at 11:37
  • You have to create a table that contains all ```Interests``` data. This new table will have a N-to-N relationship with person table – 0xNIC Mar 03 '23 at 11:44

1 Answers1

0

Depending on version you can use STRING_SPLIT If using a very old version of SQL you can write a UDF to do it - examples here

CHill60
  • 1,180
  • 8
  • 14