Skip to content
Advertisement

Is there a way to split text from cell into multiple records in SQL using line break delimiter?

I have a system generated report that exports all expense reports for a given period. All employees attached to the report are exported in one field “Attendees”, separating multiple employees with line breaks.

I would like to break the cell into multiple records, still including the expense report NO. on each record.

Note, the names in the attendee field are different formats, but they all end with a “)”.

Is there a way to use the line break as a delimiter and create a new record with each break, and populate with the same values of the other fields in the original record?

SQL would be the ideal interface, but I can use Python, R, Tableau, and PowerBI before importing into the server if need be.

Example below.

System Generated Report & Desired Result

Advertisement

Answer

SQL Server:

Oracle:

MySQL: (Only valid for examples where you will have 5 different employees in column Attendees. If yes then add union all…)

Note It would be nice that one of this will be of use to you but next time do add a tag of a database you use.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement