用上面的方法可以,但用虚拟表更简单, select top 20 * into #aa from notemaster while (select count(*) from #aa)>10 begin delete #aa where ReNo=(select top 1 ReNo from #aa) end select * from #aa drop table #aa
直接用select语句不可以吗?这样速度最快,否则分页就没什么意思了
要有一唯一字段 如:id select top 10 * from table where id not in (select top 10 id from table )
select top 20 * into #aa from notemaster
while (select count(*) from #aa)>10
begin
delete #aa where ReNo=(select top 1 ReNo from #aa)
end
select * from #aa
drop table #aa
select top 10 * from table where id not in (select top 10 id from table )