I need a function or procedure in SQL Server 2014 that can read the content between (<?>
) the sign tags for this example.
Thanks.
<ul>how are you?</ul>
Output1: should be ul
or /ul
Is this possible?
I need a function or procedure in SQL Server 2014 that can read the content between (<?>
) the sign tags for this example.
Thanks.
<ul>how are you?</ul>
Output1: should be ul
or /ul
Is this possible?
If you requirement is too simple to just read content between a tag then you can use the following logic:
declare @str varchar(200) = '<ul>how are you?</ul>'
select SUBSTRING(@str, CHARINDEX('<', @str) + 1, CHARINDEX('>', @str) - CHARINDEX('<', @str) -1)
However, this will not work if you have multiple tags in the same string. If you need to handle more complex scenario you can use xquery. I think this link might help you to do so: xquery to return the element name