I\'m running a query from SQL Server Management Studio 2005 that has an HTML file stored as a a string, e.g.:
SELECT html
FROM table
Thi
column with line breaks: "mycolumn"
SELECT REPLACE(REPLACE(mycolumn, CHAR(13), ''), CHAR(10), '') as `mycolumn` FROM mytable
This replaces the linebreaks.
I don't see where you will have much success exporting html to csv - it's really not what csv is meant for. You would be better off using an xml format, where the html code can be enclosed in a cdata element.
That said, you could try using the Replace function to remove the line breaks, and you could manually add the quotes - something like this:
select '"' + replace (replace (html, char(10), ''), char(13), '') + '"'
If your html value could have double quotes in it, you would need to escape those.
I got around this limitation by creating an Access database, using the "Link to the data source by creating a linked table" feature, opening the "linked" table, then copy/paste to Excel from there. Excel can save the CSV data as needed. You should be able to connect directly from Excel too, but the "linked table" feature in Access let me set up several tables at once pretty quickly.