to select from 5 to 10 rows from a table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

to select from 5 to 10 rows from a table

hi all
there is a table containing 30 rows in the predefined manner….and i need to select rows from 5 to 10 which are currently in the table….help me in writing the query for the same

You need pagination Madhivanan Failing to plan is Planning to fail
Well.. here is the excellent link for paging i had come across so far.. IF you want in the SQL its self.. do post your table structure and which version of SQL SERVER you are using.. Chirag
SELECT TOP y fields
FROM table
WHERE conditions
ORDER BY table.field ASC) as foo
ORDER by field DESC) as bar
ORDER by field ASC
You replace x & y various with desirable numbers. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.