i want to extract a variable string from an ntext field.
Sample Data in Background_text (ntext)
function changeFocus() { document.getElementById('skipContent').style.visibility = 'visible'; document.getElementById('flashContent').blur();
document.getElementById('skip').focus(); } </script> </head> <body onload='hideDiv()'> <div id="flashContent" align="center"> <object
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="440" id="Animation" align="middle"> <param name="movie"value="/assets/abc/images/abcdef.swf" /> <param name="quality" value="high" />
I want to extract this data: "/assets/abc/images/abcdef.swf"
The string will always be preceded by value=" AND end in.swf"
As a first attempt, I tried
SELECT SUBSTRING([Background_text], CHARINDEX('value="/assets/', [background_text]) + 15, LEN(convert(varchar(max), background_text) -
CHARINDEX('value="/assets/', [Background_text]) + 15) - 1)
but I received this error
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value ....... to data type int
This query won't completely accomplish what I want. Do you have a suggestion?
Thanks.