我有一列返回一行HTML文本。当我将结果复制到Excel时,该列将使用HTML代码格式化电子表格。
我正在尝试删除换行符,以便将结果保留在一行中。
我设法使用下面的代码删除了
,但是现在输出将所有结果压缩为一行,而不仅仅是一行。
例如
所需结果
<br>Column1 Column2 Column3
<br>A 1 <html><head><p>I have a question</p><p>Here is the answer to my question</p></html>
<br>B 2 <html><head><p>Hello world</p><p>This is a response</p></html>
<br>C 3 <html><head><p>Do you have another question</p><p>I have another question</p></html>
当前结果
A 1 <html><head><p>I have a question</p><p>Here is the answer to my question</p></html>B 2 <html><head><p>Hello world</p><p>This is a response</p></html>C 3 <html><head><p>Do you have another question</p><p>I have another question</p></html>
到目前为止已尝试的代码
(Column3中包含HTML)
SELECT
Column1
,Column2
,REPLACE(CAST(Column3 AS CHAR), '<br%','')
FROM
Table1
WHERE
CAST(Column3 AS VARCHAR(MAX) LIKE '%m%'
答案 0 :(得分:1)
您可以使用REPLACE
删除回车符和换行符:
REPLACE(REPLACE(YourColumn,CHAR(13),''),CHAR(10),'')