替换包含html数据的SQL Server表列中的所有URL

时间:2018-09-11 13:53:58

标签: sql sql-server tsql

我有一个SQL Server表列,其中包含带有格式为href="/page/random_id1/random_id2"的链接的html内容。

这里random_id1是一个向导,而random_id2是一个子弹。现在,我想运行一个SQL查询,该查询可以通过将所有href值转换为href="/page/random_id2"来替换它们。

在这里,请注意,我正在从每个Herf中移除random_id1部分。

这是一个示例查询:

select top 1 id, htmlcode from tenantpage;

03781776-5f64-4c59-a6f7-5873e0b9f128
<div>test</div><a href="/page/54171776-1f64-4c56-b6f9-7140e0b9fcs1/read-article1">Link</a><div>something else <span>test <a href="/page/32151776-1f64-4c56-b6f9-7120e0b9f012/read-article1-test">Link</a></span></div><a href="/page/76231758-0f69-0c56-x6f5-7120e0b9f01a/best-answers">Link</a>

我不知道这是否可行,请在这里提供帮助。

0 个答案:

没有答案