Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 14:54:48
Original
1406 people have browsed it

替换SQL Server数据库中所有表的所有字段的某些内容--方法一 替换 表字段 内容 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(''+quot

替换SQL Server数据库中所有表的所有字段的某些内容--方法一 替换 表字段 内容
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'
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template