logo

Replacing Carriage Return With Space

Jame posted on Wednesday, April 04, 2007 12:14 PM

I have a select query that I import to Excel. when I open it in Excel I
notice the rows with a carriage return dont work.
Is there a way to replace the carriage return char code with the space char
code durnig the execution of my sql select query.
Thes steps I am taking are:
1 In query designer I select Results To File...
2 I run my Select Query, saving as an rpt file
3 I open up Excel and import.
during step #2 in addition to selecting can I also parse columns and replace
carriage return with space. I am using sql server 2000. Thanks.

SELECT REPLACE(REPLACE(REPLACE(column_name, CHAR(10) + CHAR(13), ' '),

Aaron Bertrand [SQL Server MVP] posted on Wednesday, April 04, 2007 12:32 PM

SELECT REPLACE(REPLACE(REPLACE(column_name, CHAR(10) + CHAR(13), ' '),
CHAR(10), ' '), CHAR(13), ' ')
FROM table_name

--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006


Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Create Account & Ask Question In Live Forum





Pete's Resume  |  Robbe's Resume  |  Neado  |  Free Icons  |  Privacy  |   (c) 2010