急求帮助! 数据库里被病毒安上了一堆垃圾代码
数据库里被病毒安上了一堆垃圾代码:如id title
1 123aaaaa
2 456aaaaa
3 789aaaaa
aaaaa为垃圾代码,长度未知,但长度都相同,求一语句 aaaaa全部替换为空。
急!谢谢 我写了一游标来处理,,貌似不行
declare re_cur scroll cursor for select title from article
open re_cur
fetch next from re_cur
while @@fetch_status = 0
begin fetch next from re_cur
declare @aa varchar(8000)
select @aa = title from article
update article set title = left(@aa,len(@aa)-134) --134为垃圾代码长度
end
close re_cur
deallocate re_cur
GO 斑主在吗? 非常着急~! 帮帮忙啊。。 create table tb (id int identity(1,1),title varchar(2000))
insert into tb (title) select '123aaaaaa' union all select '456aaaaaa' union all select '6aaaaaa'
update tb set title = replace(title,'a','')
select * from tb
drop table tb 我有几 万条记录,楼上的方法不能一个个SELECT吧
不行哦。。谢谢楼上 你看清楚点再说 楼上的SELECT 是用来插入测试数据的 楼上的方法就很好 我自己解决了,,谢谢朋友
还是游标
declare @id int
declare re_cur cursor for select [id] from article
open re_cur
fetch next from re_cur into @id
while @@fetch_status = 0
begin
declare @aa varchar(8000)
select @aa = title from article where id = @id
update article set title = left(@aa,len(@aa)-134) where id = @id
fetch next from re_cur into @id
end
close re_cur
deallocate re_cur
GO 呵呵,即然都有四个a,那就全部删除掉了
delete * from 表名 where 字段 like "aaaa"
页:
[1]
