sql数据库批量修改所有表中的字段

sql数据库批量修改所有表中的字段
sql数据库中,有a,b,c三个表,每个表中都有多个列,其中列的内容里面含有“hhh”字段,我想把“hhh”换成“www“,请问如何写update语句
不是修改全部内容,比如说a、b、c表中不确定列中的内容是“uuuuyyyuuuu”我想把内容换成“uuuutttuuuu”,怎么样批量换啊!
----先删除要处理字段念做闷的默认值约仔弯束
declare @s varchar(8000)
set @s=''
select @s=@s+'
alter table ['+b.name+'] drop constraint ['+d.name+']'
from syscolumns a
join sysobjects b on a.id=b.id
join syscomments c on a.cdefault=c.id
join sysobjects d on c.id=d.id
where b.name='KeyWords'
and (a.name='hits')
exec(@s)

----如果要要将 hits 字段改为数字类型
alter table KeyWords alter column [hits] numeric(18,0)

----再为字段胡耐 hits 添加默认值约束
set @s='alter table KeyWords add constraint
[df__t1__hits__'+cast(newid() as varchar(36))
+'] default (0) for hits'
exec(@s)
go

--如果要改已有的数据
update KeyWords set hits=0 where 1=1
使用存储过程。
update 表名 set 字段=replace(字段,'hhh','www')
← 上一篇: 下一篇: →