批量替换数据库所有表中的内容
写个东东用来搞定数据库中的恶意脚本代码
select
'update ['+s.name + '] set ['+c.name+']=' +'replace(['+c.name+'],''小白'','''')'
from sysobjects s,syscolumns c,systypes t
where s.type='u' and s.id=c.id
AND OBJECTPROPERTY(s.id,N'IsUserTable')=1
AND c.xusertype=t.xusertype
AND t.name IN('varchar','nvarchar','char','nchar')
union
select
'update ['+s.name + '] set ['+c.name+']=' +'replace(Cast(['+c.name+'] as varchar(8000)),''小白'','''')'
from sysobjects s,syscolumns c,systypes t
where s.type='u' and s.id=c.id
AND OBJECTPROPERTY(s.id,N'IsUserTable')=1
AND c.xusertype=t.xusertype
AND t.name IN('text','ntext')
'update ['+s.name + '] set ['+c.name+']=' +'replace(['+c.name+'],''小白'','''')'
from sysobjects s,syscolumns c,systypes t
where s.type='u' and s.id=c.id
AND OBJECTPROPERTY(s.id,N'IsUserTable')=1
AND c.xusertype=t.xusertype
AND t.name IN('varchar','nvarchar','char','nchar')
union
select
'update ['+s.name + '] set ['+c.name+']=' +'replace(Cast(['+c.name+'] as varchar(8000)),''小白'','''')'
from sysobjects s,syscolumns c,systypes t
where s.type='u' and s.id=c.id
AND OBJECTPROPERTY(s.id,N'IsUserTable')=1
AND c.xusertype=t.xusertype
AND t.name IN('text','ntext')
版权声明:本文原创发表于 博客园,作者为 imbob,博客 http://imbob.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。