May 5, 2008 at 9:16 am
Hello,
I have nvarchar records with carriage return and I would like to replace it with "break".
How can I can do it?
Thank you,
Augusto
May 5, 2008 at 11:05 am
Augusto,
If by "break" character you mean an ascii control-o you ought to be able to use the REPLACE function with something such as:
declare @cr_char char(1) set @cr_char = char(13)
declare @break_char char(1) set @break_char = char(15)
declare @test-2 varchar(25)
set @test-2 = 'This is' + char(13) + ' a test.'
select @test-2 as [@test]
select replace(@test, @cr_char, @break_char) as [replace()]
/* -------- Sample Output: --------
------------------
This is
a test.
(1 row(s) affected)
replace()
-----------------
This is a test.
(1 row(s) affected)
*/
Do you also want the CARRIAGE RETURN / LINE FEED combination replaced with a break function? Because the replace function as I just listed will leave behind the LINE FEED char. The code can be readily adjusted to solve this problem if necessary.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply