We have the below query which was written to replace any & in a memo field with the HTML equivalent (&). When written, we did not consider that there are potentially other HTML tags in the field which also begin with “&” (i.e. — " etc). Since we must ensure that all ampersands are the HTML equivalent when used alone and not part of another tag we must skip those which at part of another tag. That said, the shortest HTML tag which can start with & seems to be 3 characters, and the longest seems to be six characters, so & _ _ _ ; to & _ _ _ _ _ _ ; in length ... are there any ideas on updating the where clause so that it does not update any & which are proceeded with a ";" in the next 4-7 characters after a &? Thank you.
UPDATE STOCKMEM
SET INETFDESC = CAST(
REPLACE(
REPLACE(
CAST(INETFDESC as NVarchar(MAX))
,'&','&')
, '&', ,'&')AS NText)
WHERE INETFDESC LIKE '%&[^amp;]%'