Tuesday, March 20, 2012

Replace <br> tag in CRLF

Hi all,

I made a migration operation and when I am looking inside database I can see the <BR> tags.

The question is how to write a query that replace all of this occurances of <BR> inside the colum table, with CLRF which is a new line code.

Thanks in advance.

REPLACE(my_string_field, '<br>', chr(13) + chr(10)) will do the replace in a field...so maybe a query like this would work?

UPDATE MY_TABLE
SET MY_STRING_FIELD = REPLACE(MY_STRING_FIELD, '<br>', chr(13) + chr(10));

give or take|||

We are close but not yet. I needded to change the code so it will work.

The conversion is working but all the characters become question mark like this: "?? ? ?? ?? ?? ?? ???? ? ?? ?"

I tried 2 types of the unicode that one of them should be the one I am using, but still the quotation marks is there...here is the query please help:

UPDATE [E:\WEBSITES\A1\TBH_WEB\APP_DB.MDF].[dbo].[tbh_Comments]
SET
[Body] =REPLACE((CAST([Body]AS varChar(1000)) COLLATE SQL_Latin1_General_CP1_CI_AS),'<br>',char(13) +char(10))

No comments:

Post a Comment