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
 General SQL Server Forums
 New to SQL Server Programming
 Removing Carriage Returns

Author  Topic 

pgmr1998
Yak Posting Veteran

66 Posts

Posted - 2010-09-29 : 15:53:08
I have a select query that I use to build a text file for import to another application. However, when I open it using WordPad or any text editor, I notice that some rows are being broken up because there is a certain column that contains a carriage return. Well, this causes the application to not work.
Is there a way to replace the carriage return char code with the space char code during the execution of my sql select query for the field in question? Please help!

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2010-09-29 : 16:22:43
Here's one way:

declare @s varchar(50)
set @s = 'this is
a test'

select replace(@s, char(13)+char(10), ' ')


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -