ALTER PROCEDURE [dbo].[get_data] (
@rowsPerPage int,
@pageNum int
)
AS
BEGIN
WITH sqlpaging
AS
(
SELECT TOP(@rowsPerPage * @pageNum) ROW_NUMBER() OVER (ORDER BY UPPER(formal_name)) as resultNum
, rd.id
, fss.id AS status_table_record_id
, fss.status
, UPPER(formal_name) AS formal_name
, sis_code
, prog
, ISNULL(chartfield,'') AS chartfield
FROM ref_donor rd
LEFT JOIN fundraising_scholarship_status fss ON rd.id = fss.scholarship_id
)
SELECT * FROM sqlpaging WHERE resultNum > ((@pageNum - 1) * @rowsPerPage)
END;
|