代码如下:
select * into #temp from Authors
declare @count int;
declare @Au_ID int;select @count = count(*) from #temp
while (@count > 0)
begin
select @Au_ID = max(Au_ID) from #temp ;
select @Au_ID;
delete from Authors where Au_id = @Au_ID;
select @count = count(*) from #temp
end
drop table #temp;
select * into #temp from Authors
declare @count int;
declare @Au_ID int;select @count = count(*) from #temp
while (@count > 0)
begin
select @Au_ID = max(Au_ID) from #temp ;
select @Au_ID;
delete from Authors where Au_id = @Au_ID;
select @count = count(*) from #temp
end
drop table #temp;
declare @count int;
declare @Au_ID int;select @count = count(1) from #temp
while (@count > 0)
begin
select @Au_ID = max(Au_ID) from #temp ;
select @Au_ID;
delete from #temp where Au_id = @Au_ID; --Authors改#temp 不然死循环
select @count = count(1) from #temp
end
drop table #temp;
declare @count int;
declare @Au_ID int;select @count = count(*) from #temp
while (@count > 0)
begin
select @Au_ID = max(Au_ID) from #temp ;
select @Au_ID;
delete from #temp where Au_id = @Au_ID;
delete from Authors where Au_id = @Au_ID;
select @count = count(*) from #temp
end
drop table #temp;
declare @count int
declare @Au_ID intselect @count = count(*) from #temp
while (@count > 0)
begin
select @Au_ID = max(Au_ID) from #temp
select @Au_ID
delete from Authors where Au_id = @Au_ID
select @count = count(*) from Authors
end
drop table #temp