A close-up of colorful yarn strands in various hues on a brown backdrop, perfect for craft and DIY themes.
|

Python for analyst – string split

The task is to convert html field to url.

Row date we can get via this query

select [Id], [Name], html
 FROM [DBPromoHeader]
where Html is not null and Html like '%href%'

We got data like this

We can use string_split to convert html field to url.

select [Id], [Name], html, replace(replace(value,'href="','https://mietwood.com/'),'"','') Promo_url
 FROM [DBPromoHeader]
 cross apply string_split(Html,' ')
 where Html is not null and Html like '%href%' and value like 'href%'
 order by [Id]

After that we got following result

Happy coding.

Similar Posts