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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 replace char(10) & char(13) in a text field

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-06-23 : 17:58:43
replace char(10) & char(13) in a text field

I have a text field that has multpile char(10) & char(13) i want to select replace with '*'

any help appreciated.

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-06-23 : 18:19:10
[code]DECLARE @a varchar(10)
SELECT @a = 'a'+char(10)+'b'+char(13)+'c'
SELECT @a AS Original, REPLACE(REPLACE(@a, char(10), '*'), char(13), '*') AS New[/code]

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2009-06-23 : 18:56:21
If OP actually meant "text field" as in text datatype, then you'll need to first cast as varchar(max) to use replace function.

SELECT @a AS Original, REPLACE(REPLACE(cast(@a as varchar(max)), char(10), '*'), char(13), '*') AS New
Go to Top of Page
   

- Advertisement -