I have the following query:
SELECT
substring(Content, charindex(N'<img src=''http://tex.', Content),
charindex(N'class=''latex-formula''>', Content)+22) as Img
FROM
[Scyk].[dbo].[Posts]
WHERE
content LIKE '%<img src=''http://tex.%'
Now I would expect it to give me all <img> tags that I have in database. But instead, it returns something like this:
<img src='http://tex.z-dn.net/?f=x%3Dlog_%7B%5Csqrt%7B2%7D%7D64' id='TexFormula' onerror="texError(this)" title='x=log_{\sqrt{2}}64' alt='x=log_{\sqrt{2}}64' align='absmiddle' class='latex-formula'> to:</p><p>a)
Where the end of the string ends randomly, it can be few characters too many, or it can be plenty characters too many. What is wrong in my query?