I have a ntext (or nvarchar(max)) column which contains HTML text for example:
<P>Hello <IMG title="" border=0 alt="" src="files/1.JPG"></P>
<P> </P>
<P><IMG title="" border=0 alt="" src="files/folder1/2.JPG"></P>
<P> </P> World!
<P><IMG title="" border=0 alt="" src="files/folder2/files/3.JPG"></P>
<P> </P>
<P><IMG title="" border=0 alt="" src="files/4.JPG"></P>
Now I need to replace each path of the src from files/ to files/new/ (or to other path) but only those with path of files/.
a REPLACE won't work (I think) because it would change also files/folder1/ and files/folder2/.
In the above example, I need to only change the path for 1.JPG and 4.JPG.
How can I do it? (The question is specific to sql-server).
Note: The file names/content can vary. the above HTML is just an example.
 
     
     
    