Monday, March 12, 2012

Paging in Sqlserver 2000

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 : like ROW_NUMBER in SqlServer 2005 and ROWNUM oracle.There are several methods for doing this. Which is most efficient depends upon your specific circumstances.

One method involves fabricating a rownumber with a subquery. This can be done as a single SQL statement (like a view) but is not very efficient.

Another method is to use nested TOP statements. This method is reasonably fast, but when calling TOP N the N cannot be a variable. So you must either hard-code it or use dynamic sql.

One more method is to select your data into a temporary table with a defined identity value. You can use the identity values created as row numbers. This method is fairly fast, but requires multiple steps and so must be implemented as a procedure.

No comments:

Post a Comment