我想在SQL Server中通过删除其所有html内容来更新数据。删除并替换SQL中的所有html内容
请参阅下面的示例数据。
这是一个示例文本。
<html><head></head><body><p>This is a sample text.</p></body></html>
我只需要保留纯文本并删除所有这些HTML内容,包括标签。我认为,参考可能从<html*
到*/html >
有什么建议吗?
我想在SQL Server中通过删除其所有html内容来更新数据。删除并替换SQL中的所有html内容
请参阅下面的示例数据。
这是一个示例文本。
<html><head></head><body><p>This is a sample text.</p></body></html>
我只需要保留纯文本并删除所有这些HTML内容,包括标签。我认为,参考可能从<html*
到*/html >
有什么建议吗?
Charindex
+ While Loop
。尝试这个。
DECLARE @html VARCHAR(5000)='This is a sample text <html><head></head ><body><p>This is a sample text.<p></body></html>',
@start INT,
@end INT
WHILE Charindex('<', @html) > 0
BEGIN
SET @start= Charindex('<', @html)
SET @end = Charindex('>', @html)
SELECT @html = Stuff(@html, @start, (@end - @start) + 1, '')
END
SELECT @html --This is a sample text This is a sample text.
您好,感谢,将在应用到具有HTML的所有行? 每个记录都有纯文本版本以及它的html版本。 – Mark 2015-03-04 05:30:35
这将删除< and >之间的所有词 – 2015-03-04 05:32:17
使用替换功能,您可以通过此功能,以空格代替<,,> – 2015-03-03 04:53:30