create proc max_speed @table nvarchar(20), @currentpage int, @pagesize int, @orderby nvarchar(20) as begin declare @s varchar(1000) set @s = 'SELECT TOP '+rtrim(@pagesize)+' * FROM '+@table+' WHERE ('+@orderby+' NOT IN (SELECT TOP '+rtrim(@pagesize*@currentpage)+' id FROM '+@table+' ORDER BY '+@orderby+')) ORDER BY '+@orderby+'' exec(@s) end
@table nvarchar(20),
@currentpage int,
@pagesize int,
@orderby nvarchar(20)
as
begin
declare @s varchar(1000)
set @s = 'SELECT TOP '+rtrim(@pagesize)+' * FROM '+@table+'
WHERE ('+@orderby+' NOT IN
(SELECT TOP '+rtrim(@pagesize*@currentpage)+' id
FROM '+@table+'
ORDER BY '+@orderby+'))
ORDER BY '+@orderby+''
exec(@s)
end