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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Exporting to CSV (minus LF & CR)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SergioM
Posting Yak Master

170 Posts

Posted - 11/23/2012 :  11:47:08  Show Profile  Reply with Quote
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 - 11/23/2012 :  13:08:48  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000