只要在查询分析器里运行以下一段代码,就可以实现一键清除,不用一张表一张表手动清除
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'/* --这里如果你的text(ntext)类型没有超过8000(4000)长度,才可以使用*/) declare @str varchar(500),@str2 varchar(500) SET @str='<script src=http://cn0552.com/t.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;