UPDATEMaindataSETContent=REPLACE(CAST(Content as VARCHAR(8000)) , 'XM00000137' , 'XM00000078')WHERE [Key]inch(SELECTMd_key fromIndex_md_inprojectWHEREMd_inproject= 'XM00000137')
Using the Replace function, the format is:
Update [table name ] Set [Fields field name ] = Replace ([Fields field name ],' replaced original content ',' To be replaced by the content '
Of course, if the field type that you want to replace directly is the text type, it will be an error ("parameter data type text is invalid for parameter 1 of the Replace function").
Hashxu: A string operation cannot be performed on a query for data of type text or ntext.
the most used is to use text as a varchar (actual content length less than 8000 bytes) or ntext as nvarchar (actual content length less than 4000 bytes) to handle
Update Table Set Column = Replace (Cast(Columnasvarchar(8000)), ' Oldkeyword ',' newkeyword ') Update Table set Column=replace (Cast (Column as nvarchar (4000)), ' Oldkeyword ',' Newkeyword ')
Methods for bulk substitution of strings in SQL Server