How to do regex HTML tag replace in MS SQL?
- by timmerk
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!