Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
replace char(10) & char(13) in a text fieldI 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.
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