Search

Monday, February 25, 2013

Replace carriage return and line feed in a SQL server varchar field

I have been facing an issue while importing some data from SQL to CSV file. In one of my SQL fields user entered Enter Key or Line feed, because of that my exported CSV file was not in good format. Rows were broken in between. The bwloe query replaces the Carriage return and line feed with 'a space:

SELECT REPLACE(REPLACE(Remarks, Char(10),' '), Char(13), ' ') as Remarks FROM DemoTable


No comments:

Post a Comment