如果不用判断的话,假设有一个字段:AAA,可做如下过程: declare @fieldaaa int declare @tempaaa int declare @i int declare cur cursor for select aaa from table open cur fetch next from cur into @fieldaaa select @tempaaa=@fieldaaa select @i=1 while @@fetch_status<>-1 begin while @@fetch_status<>-1 begin if @@fetch_status=-1 break fetch next from cur into @fieldaa if @fieldaaa=@tempaaa delete from table where current of cur end select @i=@i+1 fetch absolute @i from cur into @fieldaaa if @@fetch_status=-1 break select @tempaaa=@fieldaaa end 在网吧写的,没运行,不知道行不行?
declare @fieldaaa int
declare @tempaaa int
declare @i int
declare cur cursor
for select aaa from table
open cur
fetch next from cur into @fieldaaa
select @tempaaa=@fieldaaa
select @i=1
while @@fetch_status<>-1
begin
while @@fetch_status<>-1
begin
if @@fetch_status=-1
break
fetch next from cur into @fieldaa
if @fieldaaa=@tempaaa
delete from table where current of cur
end
select @i=@i+1
fetch absolute @i from cur into @fieldaaa
if @@fetch_status=-1
break
select @tempaaa=@fieldaaa
end
在网吧写的,没运行,不知道行不行?