Split Field by Line Break in PostgreSQL

Standard

Broken LinesIn one of the PostgreSQL systems we work with often, there is only one street address field. To get around the need for a change to the table structure, our IT folks simply use a new line character (\n) to denote that there is a second line of address information. The problem becomes, when we go to generate a mailing list, how can we export a list to send to the mailhouse with all address information on one line?

The answer is to use the SPLIT_PART function. See the example below: Continue reading