ALTER PROCEDURE [dbo].[getNumListPagedOrder]
@pageIndex int,
@maximumRows int,
@sortorder nvarchar(20)
AS
DECLARE @Query VARCHAR(1000)
DECLARE @CalcValue1 INT
DECLARE @CalcValue2 INT
SET @CalcValue1 = (@pageIndex-1)*@maximumRows)
SET @CalcValue2 = (@pageIndex * @maximumRows )+1
SET @Query = '
SELECT [dwg no#], [drawing title], pk, rowid
FROM (
SELECT [dwg no#] , [drawing title], pk,
row_number() over (order by ' + @sortorder + ') as rowid from numlist ) as NumListNumbered
where rowid > (' + Cast(CalcValue1 AS VARCHAR(20)) + ') and rowid < (' + CAST(@CalcValue2 AS VARCHAR(20)) + ')'
EXECUTE(@Query)
GO
|