How to do regex HTML tag replace in MS SQL?
Posted
by timmerk
on Stack Overflow
See other posts from Stack Overflow
or by timmerk
Published on 2010-04-12T15:21:13Z
Indexed on
2010/04/12
15:23 UTC
Read the original article
Hit count: 315
I have a table in SQL Server 2005 with hundreds of rows with HTML content. Some of the content has HTML like:
<span class=heading-2>Directions</span>
where "Directions" changes depending on page name.
I need to change all the <span class=heading-2>
and </span>
tags to <h2>
and </h2>
tags.
I wrote this query to do content changes in the past, but it doesn't work for my current problem because of the ending HTML tag:
Update ContentManager
Set ContentManager.Content = replace(Cast(ContentManager.Content AS NVARCHAR(Max)), 'old text', 'new text')
Does anyone know how I could accomplish the span to h2 replacing purely in T-SQL? Everything I found showed I would have to do CLR integration. Thanks!
© Stack Overflow or respective owner