Hello
If i have a select query and i need to get it result by paging(for example from row x to row y ) without using cursor .
Is there any way to do it ?
Nb : Maybe like ROW_NUMBER in SqlServer 2005 and ROWNUM in oracle.
Just an example from my own test data, but you can use something like this.
Code Snippet
DECLARE @.x INT,
@.y INT
SET @.x = 2
SET @.y = 4
select TOP (@.y-@.x+1) * from testRange
WHERE ID NOT IN ( SELECT TOP (@.x-1) ID FROM testRange)
|||The information here might help.
Paging Queries
www.aspfaq.com/2120
|||try this .Provide values for start & end variables.
Code Snippet
DECLARE @.START INT
,@.END INT
SELECT * FROM
(
SELECT ID
,RANK() OVER(ORDER BY ID) AS 'RNK'
FROM TABLE1
) T
WHERE T.RNK BETWEEN @.START AND @.END
No comments:
Post a Comment