(select top '+cast((@recsperpage*(@page-1)) as varchar(20))+' '+@id+' from ('+@sql+') t9 order by '+@sort+') order by '+@sort
print @str
exec sp_executesql @str
go
其实,以上语句可以简化为:
select top 页大小 *
from table1
where (id not in
(select top 页大小*页数 id
from 表