I work with a lot of databases (specifically, T-SQL databases) which collect form submissions in which there is a pretty large comment field. Being that this is a textarea, often people make liberal use of line breaks. Unfortunately, this wreaks havoc when you try to either copy the results from the query into Excel, or export to a CSV and then import to Excel. Even when you force double quotes around each column, Excel still happily creates a new row whenever it sees a line break.

The solution I found was to modify the SELECT query to remove the two character entities representing line breaks and new lines in T-SQL, which are CHAR(13) and CHAR(10). This should cover your bases for the new line characters CR, LF, and CR+LF.

The specific SQL looks like this:

{% highlight sql %} SELECT REPLACE(REPLACE(@str, CHAR(13), ' '), CHAR(10), ' ')
{% endhighlight %}

You can, of course, replace the line breaks with something besides a single space, but I found that the best option in terms of maintaining readability in those fields once they're in a CSV.

Source: Replacing a newline in TSQL