SQL Server - Replacing Carriage Return With Space

Asked By Jame
04-Apr-07 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.
  Aaron Bertrand [SQL Server MVP] replied...
04-Apr-07 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
Create New Account
help
Export to Excel SQL Server SQL Server 2005 Enterprise: Server does not have MS Office installed. Is it still possible to export query result to Excel? Regards, Bubbles SQL Server Programming Discussions SQL Server (1) Excel (1) Yes - - Regards, Dave Patrick . . . . Please no email
call Excel subroutine from SQL Server? SQL Server Hi, What are my options for calling an Excel VBA subroutine (let us say it is in Has anyone achieved this, or have any pointers? Thanks, Fred SQL Server Programming Discussions SQL Server (1) Excel (1) Create (1) View (1) Database (1) Hi Fred
Using TSQL to export to Excel SQL Server SQL Server 2005 Enterprise: I need to export several tables into one Excel spreadsheet, each table into a specific worksheet. Is this possible using TSQL programming? How? If not, what are other options? How? (used DTS in SQL Server 2000, but this facility seemed to be very well hidden in 2005) Regards, Bubbles SQL
Import e-mail messages from Exchange Server to SQL Server SQL Server Hello, How to import e-mail messages from Exchange Server to MS SQL Server 2005 table? Thanks, GB SQL Server Programming Discussions SQL Server 2005 (1) SQL Server (1
Cannot create linked server from SQL 2005 to SQL 2000 SQL Server I need to set up a linked server on SQL Server 2005 so that a SQL Server authentication account with limited privileges can access an SQL