注册 登录
编程论坛 SQL Server论坛

急求帮助! 数据库里被病毒安上了一堆垃圾代码

orliubc 发布于 2008-05-09 14:58, 1102 次点击
数据库里被病毒安上了一堆垃圾代码:如
id  title
1    123aaaaa
2    456aaaaa
3    789aaaaa

aaaaa为垃圾代码,长度未知,但长度都相同,求一语句 aaaaa全部替换为空。
急!谢谢
7 回复
#2
orliubc2008-05-09 15:03
我写了一游标来处理,,貌似不行

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
#3
orliubc2008-05-09 15:29
斑主在吗? 非常着急~!  帮帮忙啊。。
#4
lff6422008-05-09 15:45
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
#5
orliubc2008-05-09 15:59
我有几 万条记录,楼上的方法不能一个个SELECT吧
不行哦。。谢谢楼上
#6
happynight2008-05-09 16:17
你看清楚点再说 楼上的SELECT 是用来插入测试数据的 楼上的方法就很好
#7
orliubc2008-05-09 16:41
我自己解决了,,谢谢朋友
还是游标

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
#8
dxformat2008-05-12 12:46
呵呵,即然都有四个a,那就全部删除掉了
delete * from 表名 where 字段 like "aaaa"
1