I have the following string and am trying to select only the characters before the last "</>". How can I do this?
declare @String varchar(500)
set @String = '<p>Assessed By: Michael Jordan Yagnesh</p>
<p>Reviewed By: Fred Smith</p>
<p>Home Address</p>'
select REVERSE(substring(REVERSE(@String),5,charindex(':',REVERSE(@String))-5))
Here is what I tried so far:
SELECT SUBSTRING(@String,CHARINDEX('</p>',@String,(CHARINDEX('</p>',@String)+1))-11, LEN(@String)-CHARINDEX('</p>',@String)-20) SELECT RIGHT(@String,CHARINDEX('</p>',REVERSE(@String),0)-1) select LEN(@String) select charindex('Reviewed By: ',(@String)) select charindex('Reviewed By: ',Reverse(@String)) + datalength('</p>')+1,len(@String) select SUBSTRING(@String, 61,10)
Ryan D