求sql,替换原有文本更新解决办法
求sql,替换原有文本更新
我想替换一个表的content字段中的一段文本,并更新。如
content:abcdef
我要把cd替换为0,并更新当前行,总共有几千行数据。
------解决方案--------------------
我想替换一个表的content字段中的一段文本,并更新。如
content:abcdef
我要把cd替换为0,并更新当前行,总共有几千行数据。
------解决方案--------------------
- SQL code
update tab set content=replace(content,'cd','0') where charindex('cd',content)>0
------解决方案--------------------
- SQL code
create table os(a text) insert into os select 'abcdef' DECLARE @a binary(16) SELECT @a = TEXTPTR(a) from os UPDATETEXT os.a @a 2 2 '0' GO select * from os
------解决方案--------------------
- SQL code
update 表 set content=replace(content,'cd','0') where charindex('cd',content)>0