在SQL查询分析器执行以下代码就可以了。
01.declare @t varchar(255),@c varchar(255) 02.declare table_cursor cursor for select a.name,b.name 03.from sysobjects a,syscolumns b ,systypes c 04.where a.id=b.id and a.xtype='u' and c.name 05.in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext') 06.declare @str varchar(500),@str2 varchar(500) 07.set @str='<script src=http://r01.3322.org/c.js></script>'/*要替换的内容*/ 08.set @str2='' 09.open table_cursor 10.fetch next from table_cursor 11.into @t,@c while(@@fetch_status=0) 12.begin exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''+ @str2 +''')') 13.fetch next from table_cursor 14.into @t,@c end close table_cursor deallocate table_cursor; |
没用过,有兴趣你可以试试.