/****** Script for SelectTopNRows command from SSMS ******/
How to Create paging in SQL SERVER 2005 / 2008
DECLARE @RowStart INT;
DECLARE @RowEnd INT;
SET @RowStart =20;
SET @RowEnd = 30;
WITH areainfo AS
(
SELECT [pk_Area_Id]
,[Area_Code]
,[Area_Name]
,[Area_City_Id]
,[Area_PinCode]
,[Area_CreatedBy]
,[Area_CreatedDate]
,[Area_Lastmodifyby]
,[Area_LastmodifyDate]
,[Area_IsActive]
,ROW_NUMBER() OVER (ORDER BY [Area_Name]) AS RowNumber
FROM [katemp].[dbo].[Gen_Area_Mst]
)
SELECT * FROM
areainfo
--Where RowNumber >= 31 and RowNumber <= 60
Where RowNumber >= @RowStart and RowNumber <= @RowEnd