MS SQL find and replace in TEXT field

Posted by incubushead on Stack Overflow See other posts from Stack Overflow or by incubushead
Published on 2010-04-14T21:09:55Z Indexed on 2010/04/14 21:13 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

I have a database in MS SQL 2005 that was brought up from SQL 2000 and is still using TEXT type fields instead of varchar(max).

I need to find and replace a string of characters in the text field but all of the examples of how to do this that I have found don't seem like they would work for me. It seems the UPDATETEXT command requires that the two parameters "insert_offset" and "delete_length" be set explicitly but the string i am searching for could show up in the text at any point or even at several points in the same cell. My understanding of these two parameters is that the string im searching for will always be in the same place, so that insert_offset is the number of spaces into the text that the UPDATETEXT command will start replacing text.

Example: Need to find: &lt;u&gt; and Replace it with: <u>

Text field example:

*Everyone in the room was <b>&lt;u&gt;tired&lt;/u&gt;.</b><br>Then they woke <b>&lt;u&gt;up&lt;/u&gt;.

Can anyone help me out with this? THANKS!

© Stack Overflow or respective owner

Related posts about sql

Related posts about updatetext