dbTalk Databases Forums  

Removing new line character

microsoft.public.sqlserver.misc microsoft.public.sqlserver.misc


Discuss Removing new line character in the microsoft.public.sqlserver.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Maziar Aflatoun
 
Posts: n/a

Default Removing new line character - 07-15-2005 , 11:49 PM






Hi,

Does anyone know a SQL statement that would remove all the \r\n (new line
character) from a column in the database (if it exists)?

Thanks
Maz.



Reply With Quote
  #2  
Old   
Danny
 
Posts: n/a

Default Re: Removing new line character - 07-17-2005 , 09:29 AM






I assume by /r/n you are actually looking for ascii 13 and 10. Use the
replace function like below. However, I usually change each to a blank
space instead of just removing them.

Create table #Test (
FullName varchar(100))

Declare @insertvalue varchar (100)
set @insertvalue = 'John' + char(13) + char(10) + 'Doe'
insert into #Test values (@insertvalue)

select * from #Test

update #Test set FullName = REPLACE ( FullName , char(13) , '')
update #Test set FullName = REPLACE ( FullName , char(10) , '')

drop table #Test

"Maziar Aflatoun" <maz00 (AT) rogers (DOT) com> wrote

Quote:
Hi,

Does anyone know a SQL statement that would remove all the \r\n (new line
character) from a column in the database (if it exists)?

Thanks
Maz.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.