替换SQL Server数据库中所有表的所有字段的某些内容--方法一

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

exec   sp_msforeachtable   @command1=N'   
  declare   @s   nvarchar(4000),@tbname   sysname   
  select   @s=N'''',@tbname=N''?''   
  select   @s=@s+N'',''+quotename(a.name)+N''=replace(''+quotename(a.name)+N'',N''''aa'''',N''''bb'''')''   
  from   syscolumns   a,systypes   b   
  where   a.id=object_id(@tbname)     
  and   a.xusertype=b.xusertype   
  and   b.name   like   N''%char''   
  if   @@rowcount>0   
  begin   
  set   @s=stuff(@s,1,1,N'''')   
  exec(N''update   ''+@tbname+''   set   ''+@s)   
  end'