User Id :    Password :      New Member   Forgot Password  
Topic: SQL Query to get record according page size
Sumit Gupta
24 Feb 2011 at 12:52 AM

How can we get record according page sizeby SQL Query?

Please give any example..

Re: SQL Query to get record according page size
Mansi Gupta
24 Feb 2011 at 12:57 AM

Hi

Check the sp below

CREATE PROCEDURE GetCategories

@SysId int,

@startIndex int,

@pageSize int,

@sortBy nvarchar(30)

AS

BEGIN

DECLARE @sqlStatement nvarchar(max), @upperBound INT

SET @sqlStatement='SELECT T.*

FROM (

SELECT ROW_NUMBER() OVER(ORDER BY ' + @sortBy + ') AS rowNumber, *

FROM tblCategory WHERE SysId='+CONVERT(VARCHAR(9),@SysId) +') AS T

WHERE rowNumber >= ' + CONVERT(VARCHAR(9), @startIndex) + ' AND

rowNumber < ' + CONVERT(VARCHAR(9),@upperBound)

EXEC (@sqlStatement)

END

Total Replies: 1
 
Featured Text Ad

Featured Ad