Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Exporting to CSV (minus LF & CR)

Author  Topic 

SergioM
Posting Yak Master

170 Posts

Posted - 2012-11-23 : 11:47:08
Within my database I have several data fields that contain Line Feeds & Carriage Returns. I would like to export those fields to CSV file, but the problem is that a CSV file is delimited by Commas (to end the column) and Line Feeds (to end the row).

What is the best way to go about exporting the data? I don't want to alter the data as it appears in my database, but I could transform it as it exports & remove CR & LF at that point.

What do you guys think?

-Sergio
I use Microsoft SQL 2008

SergioM
Posting Yak Master

170 Posts

Posted - 2012-11-23 : 13:08:48
Problem solved. If found this bit of code that replaces LF & CR. Also, my data is in NTEXT, so I had to convert it to NVARCHAR to use the REPLACE function.

REPLACE((CONVERT(NVARCHAR(MAX),MyField)), CHAR(13)+CHAR(10), '')


-Sergio
I use Microsoft SQL 2008
Go to Top of Page
   

- Advertisement -