在sql server中对text类型字段进行批量替换

作者:动易软件 来源:本站原创 点击数: 发布时间:2024年05月06日

问题描述:需要对扩展字段中的内容进行批量替换

问题解决:由于扩展字段是text类型,所以在替换的时候需要对类型进行转换,将text类型转换为varchar 字段,例如,需要将'[' 替换为'〔' ,']' 替换成 '〕' 时  (注意:执行时先备份数据库

update  PE_ContentManage_Article  set  ExtendContent= replace ( cast (ExtendContent  as  varchar (8000)) , '[' , '〔' )  where contentid=xx

update  PE_ContentManage_Article  set  ExtendContent= replace ( cast (ExtendContent  as  varchar (8000)) , ']' , '〕' )  where contentid=xx